Skip to content

Allow pending builds in paused pipelines to be aborted and automatically abort pending builds in archived pipelines - #9521

Merged
taylorsilva merged 3 commits into
masterfrom
abort-paused
Apr 10, 2026
Merged

taylorsilva merged 3 commits into
masterfrom
abort-paused

Conversation

@taylorsilva

Copy link
Copy Markdown
Member

Changes proposed by this PR

closes #9519

This PR fixes a bug and adds an enhancement.

  • Enhancement: automatically abort pending builds in archived pipelines
    • I tested and it was possible for a user to manually abort the build
  • Bug: pending builds can be aborted even when the pipeline is paused
    • This bug was introduced in v6.0.0, when a lot of changes were made to the scheduler and adjacent components. See the note for more details.

Notes to reviewer

This bug was introduced in v6.0.0 when big changes were made to the
scheduler and related db components. It was made by a change to the
JobFactory query that fetches jobs that need scheduling. The query would
filter out jobs and pipelines that were paused, making it impossible for
us to abort any builds that were part of paused jobs or pipelines.

Changing this query alone fixes the bug without any weird scheduling
regressions. The rest of the changes are to ensure we don't consume any
more resources than we need to, ensuring performance doesn't degrade
since we'll definitely fetch more builds now.

First, I had to update db.Job to include info about its pipeline being
paused or not. That leverages the existing job query already used across
the codebase. That information is exposed via the PipelineIsPaused()
func.

With this info, the scheduler can now detect if the job or pipeline is
paused and take a shorter path, skipping all the algorithm calls.

We then rely on db.Job.ScheduleBuild() to see that the job or pipeline
is paused, and not schedule any pending builds. I was also able to
remove one query from db.Job.isPipelineOrJobPaused() since the info it
queried for was now part of db.Job.pipelinePaused.

Overall there should be very minimal impact on performance from this
change.

This bug was introduced in v6.0.0 when big changes were made to the
scheduler and related db components. It was made by a change to the
JobFactory query that fetches jobs that need scheduling. The query would
filter out jobs and pipelines that were paused, making it impossible for
us to abort any builds that were part of paused jobs or pipelines.

Changing this query alone fixes the bug without any weird scheduling
regressions. The rest of the changes are to ensure we don't consume any
more resources than we need to, ensuring performance doesn't degrade
since we'll definitely fetch more builds now.

First, I had to update db.Job to include info about its pipeline being
paused or not. That leverages the existing job query already used across
the codebase. That information is exposed via the PipelineIsPaused()
func.

With this info, the scheduler can now detect if the job or pipeline is
paused and take a shorter path, skipping all the algorithm calls.

We then rely on db.Job.ScheduleBuild() to see that the job or pipeline
is paused, and not schedule any pending builds. I was also able to
remove one query from db.Job.isPipelineOrJobPaused() since the info it
queried for was now part of db.Job.pipelinePaused.

Overall there should be very minimal impact on performance from this
change.

Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
users could manually do this, but its easier to have Concourse itself
abort the pending builds for users.

Signed-off-by: Taylor Silva <[email protected]>
@taylorsilva
taylorsilva requested a review from a team April 10, 2026 17:40
Comment thread atc/db/job.go
Comment on lines +619 to +620
if j.paused || j.pipelinePaused {
return false, nil

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to check the archive status of a pipeline because an archived pipeline is also marked as paused.

@taylorsilva
taylorsilva merged commit 32d8bff into master Apr 10, 2026
12 checks passed
@taylorsilva
taylorsilva deleted the abort-paused branch April 10, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abort builds for paused pipelines

1 participant