-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provide an exclusive lock step in a pipeline to avoid concurrent builds #5471
Comments
After getting the urgent issue (#5281) fixed with my PR I continued to think in a similar direction. The principal difference is that your solution seems to put the lock on the whole pipeline run while I was thinking of having the lock on a particular step (so rather TaskRun). The reasoning beaning that there might be time consuming steps that can be concurrent. Both varieties would be useful though. |
There are also cases where the order of PipelineRuns are of importance so a lock with FIFO behaviour would be preferable. Maybe solve by storing a queue of runs in the SourceRepository? But then you need to take into consideration that the pod first in the queue might die while waiting. |
Issues go stale after 90d of inactivity. |
Stale issues rot after 30d of inactivity. |
/remove-lifecycle rotten |
Issues go stale after 90d of inactivity. |
Stale issues rot after 30d of inactivity. |
Rotten issues close after 30d of inactivity. |
@jenkins-x-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository. |
That would be nice to actually limit concurrency for specific jobs or even stages to avoid overlapping, especially, when external services are used. |
I think we want to solve it upstream in tekton, instead of jx (There's a TEP for that: tektoncd/experimental#699). We have something basic in lighthouse using max_concurrency I believe (https://github.com/jenkins-x/lighthouse/blob/main/docs/trigger/github-com-jenkins-x-lighthouse-pkg-config-job.md) |
Summary
When performing a release via GitOps we don't want to allow concurrent builds; as odd things can happen due to concurrency. We can happily process PRs concurrently - but often for releases we want to mark those as running one at a time for a given repository + branch.
Eventually this may end up being a core part of tekton: tektoncd/pipeline#1305
Until then a workaround could be to write a leadership election step of sorts - a step which blocks until it grabs a lock for being the 1 allowed pipeline for a given string (the git URL + branch)
Steps to reproduce the behavior
Run 2 release pipelines on a staging/production environment and issues can occur
Expected behavior
We force a 2nd pipeline on a given environment release to block until the first one complets
Strawman design
We already expose the pod logs into each pod via
/etc/podinfo
via the downward API. Though we should maybe be more explicit and expose the currentPipelineRun
name into pipeline via the$PIPELINE_RUN
environment variable.We could create a new step - say -
jx step pipeline lock
which does this:PipelineRun
name and the repository owner/repo/branchSourceRepository
for the owner/repo (we could expose this as a label/env var too to simplify the code)jenkins.io./lock/owner/repo/branch
on theSourceRepository
PipelineRun
namePipelineRun
annotation has the currentPipelineRun
name, the current pod is the leader and the step can terminate.leaderPipelineRun
resource to watch. The step then watches theleaderPipelineRun
until its complete/deleted and all pods which have the labeltekton.dev/pipelineRun=leaderPipelineRun
complete/failleaderPipelineRun
or pods then its time to try become the leader again, so try update theSourceRepository
againThe text was updated successfully, but these errors were encountered: