docs: Add executor starvation avoidance guide and tests#1029
Open
mPokornyETM wants to merge 2 commits intomasterfrom
Open
docs: Add executor starvation avoidance guide and tests#1029mPokornyETM wants to merge 2 commits intomasterfrom
mPokornyETM wants to merge 2 commits intomasterfrom
Conversation
Document the recommended pattern for using lockable resources in
declarative pipelines without causing executor starvation: use
agent none at the pipeline level and move agent directives into
individual stages alongside options { lock(...) }.
Add avoiding-executor-starvation.md with examples of the problem,
the solution, preparation stages, and nested multi-stage locks.
Add DeclarativePipelineExecutorStarvationTest with four scenarios:
- stage-level lock with agent none (resource name)
- stage-level lock with agent none (label)
- preparation stage without lock, deploy stage with lock
- nested stages sharing one lock
Fixes #697
Contributor
|
⏸️ Auto-merge countdown PAUSED: CI checks are not passing. The countdown will resume when all checks are green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documents the recommended pattern for using lockable resources in declarative pipelines without causing executor starvation, as discussed in #697.
Problem
When a pipeline uses
agent any(or a specific label) at the top level together withoptions { lock(...) }, every build allocates an executor before acquiring the lock. Builds waiting for the lock hold their executors hostage, blocking other jobs.Solution documented
Use
agent noneat the pipeline level and moveagentinto individual stages alongsideoptions { lock(...) }:pipeline { agent none stages { stage('Test') { options { lock('end-to-end-test-resource') } agent { label 'some-label' } steps { echo 'Running tests...' } } } }Changes
New example doc — avoiding-executor-starvation.md covering:
agent none+ stage-level agent)Updated examples index — added link to the new guide in readme.md
New test class —
DeclarativePipelineExecutorStarvationTestwith four scenarios:agentNoneWithStageLevelLockDoesNotConsumeExecutorWhileWaitingagentNoneWithStageLevelLabelLockDoesNotConsumeExecutorpreparationStageRunsWithoutLocknestedStagesShareLockWithoutExecutorStarvationCloses #697