Skip to content

Stop waiting for a pre-build run when one of its jobs fails - #122

Merged
coutoPL merged 2 commits into
masterfrom
ci/prebuild-fail-fast
Sep 11, 2026
Merged

Stop waiting for a pre-build run when one of its jobs fails#122
coutoPL merged 2 commits into
masterfrom
ci/prebuild-fail-fast

Conversation

@sscarduzio

@sscarduzio sscarduzio commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The problem

The poller read only the run status. A run with a failed job still read as running until the whole run finished, so the waiter kept polling something that could no longer succeed.

That waiter holds a paid runner. A readonlyrest_kbn pipeline run has three ubicloud-standard-8 legs waiting on the same pre-build. On 4 September that cost 78 minutes of idling for a pre-build that had already lost a job.

The change

Neither pre-build workflow sets continue-on-error, so the first job that ends in failure, cancelled or timed_out decides the run. The poller now asks for jobs as well as status, reports that job's conclusion at once, and names the job in the error:

ERROR: the ROR ES pre-build run cannot succeed: job 'build (es818x)' ended with
       'failure' after 12 min. Not waiting for the rest of the run.

Limit

This does not help a run that is still queued — nothing has failed there yet. sscarduzio/elasticsearch-readonlyrest-plugin#1372 covers the queue.

Review notes

  • Base branch is now master. docs/dev/branching.md in [RORDEV-2220] add branching, code style and writing style docs #125, case 4: a pipeline, workflow or runner change targets master. Rebased onto master, so this PR carries only its own commit.
  • The incident moved out of the comment. docs/dev/code-style.md asks a comment to explain the current state, not the event that produced it. The date, the idle cost and the other repository's runner sizes are above instead. The comment keeps only the constraint a reader cannot see from the code: the pre-build workflows do not set continue-on-error, so the first job that ends badly decides the run, and the waiter pays for the rest.

🤖 Generated with Claude Code

@coderabbitai

This comment was marked as off-topic.

@sscarduzio
sscarduzio requested a review from coutoPL September 5, 2026 17:31
@sscarduzio

This comment was marked as outdated.

@10hexdev

This comment was marked as outdated.

@10hexdev

This comment was marked as off-topic.

@sscarduzio sscarduzio changed the title Stop waiting for a pre-build run that has already lost a job Stop waiting for a pre-build run when one of its jobs fails Sep 6, 2026
@sscarduzio
sscarduzio requested a review from Dzuming September 10, 2026 06:08

@Dzuming Dzuming left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Comment thread ci/prebuild-images-lib.sh
_prebuild_run_state polled the RUN's status and conclusion, so a run whose only
meaningful job had already failed still read as "running" until the whole run
wrapped up. The waiter holds a paid runner while it polls - three
ubicloud-standard-8 legs per readonlyrest_kbn pipeline run - so that time is
billed for nothing.

Neither publish-pre-builds workflow uses continue-on-error (checked in both
repos: the ES one has a single `publish` job, the KBN one has prepare-docker-env
and publish-pre-builds), so the first job to end in failure, cancelled or
timed_out decides the run. Report that conclusion at once and let the existing
terminal branch stop the wait.

The error now names the job that decided it and how long we waited, instead of
saying the run "finished with failure" when it had not finished at all.

`skipped` is deliberately not terminal - a skipped job is normal and says
nothing about the run's outcome.

Verified the jq against every run shape, including real API output from run
32949023073:

  running, no jobs done         -> running
  running, one job FAILED       -> failure     (early bail)
  running, one job cancelled    -> cancelled   (early bail)
  running, a job merely skipped -> running
  queued, no jobs listed yet    -> running
  completed success             -> success
  completed failure             -> failure
  completed, conclusion missing -> unknown

This does not help the case where the run sits QUEUED with no jobs started -
nothing has failed yet there. That was the 78-minute wait on 2026-09-04, and
sscarduzio/elasticsearch-readonlyrest-plugin#1372 is what fixes it, by taking
the workflow off a two-slot pool.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sscarduzio
sscarduzio force-pushed the ci/prebuild-fail-fast branch from c5468ab to 4a6b867 Compare September 10, 2026 09:22
docs/dev/code-style.md asks a comment to explain the current state, not
the change or the event that led to it. The comment carried the date and
the cost of the run that showed the problem, plus the runner sizes of
another repository's pipeline. That is the PR description's job, and the
numbers are there now.

What stays is the constraint a reader cannot see from the code: the
pre-build workflows do not set continue-on-error, so the first job that
ends badly decides the run, and the waiter pays for the rest.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@coutoPL coutoPL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@coutoPL
coutoPL merged commit d83f16a into master Sep 11, 2026
84 checks passed
@coutoPL
coutoPL deleted the ci/prebuild-fail-fast branch September 11, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants