Skip to content

provide a pipeline concurrency limit #1305

Closed
@jstrachan

Description

Expected Behavior

Its common in CI systems to limit the number of concurrent pipelines that can execute on a given repository and branch. e.g. process PRs concurrently, but only allow a maximum of 1 release to be performed at once in case releases clash with each other. e.g. to avoid race conditions between concurrent pipeline steps that operate on shared git repositories/buckets/kubernetes clusters.

e.g. imagine a simple pipeline of

  • get the next incrementing version number
  • spend some time building artifacts/images
  • use kubectl to deploy some resources using this version number or update the website/changelog

If you run this pipeline concurrently all kinds of things could happen due to the wonders of concurrency (e.g. seeing the version number go forwards then backwards).

When working on separate PRs concurrency is not usually an issue; but working on shared resources (e.g. producing a sequential stream of artifacts or updating a shared cluster) we often want to force a clean ordering on the pipelines to avoid confusion or worse things.

Actual Behavior

There's currently no way to force a pipeline to not execute until all other pipelines for that repository + branch have completed without writing some kind of leader election step.

We're pondering writing a little leader election step as a workaround (which would be Jenkins X specific jenkins-x/jx#5471); but figure it would be nice to be able to add this kind of capability into the tekton controller.

If you squint its a little like the tekton controller being like the ReplicaSet controller; if replicas = 1 for a unique string (e.g. the git repository URL + branch name), only start a new Pod for a PipelineRun when no others are running for that string.

Steps to Reproduce the Problem

  1. run lots of pipelines like the above example and watch the version number go up and down

Additional Info

If there was some kind of MaximumConcurrency for a specific source repository and branch we could modify the tekton controller to only create a new Pod when it knows there are no other running pods for a given source repository + branch.

Metadata

Assignees

No one assigned

    Labels

    area/roadmapIssues that are part of the project (or organization) roadmap (usually an epic)kind/featureCategorizes issue or PR as related to a new feature.kind/questionIssues or PRs that are questions around the project or a particular featurelifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions