Repository navigation
Report cancelled and timed-out Dispatcher batches and jobs - #25505
Conversation
336803d to
f1da5e5
Compare
5cbb710 to
e076b66
Compare
✅ Dispatcher tests: passed
✅ 2 passed · nothing failed Batches · ✅ batch-01 2/2 Dispatcher finished on |
evalya-impact-summaryevalya impact analysis |
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 818845c | Docs | View more details | Give us feedback! |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e076b665ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if any(batch.status is Status.FAILURE for batch in self.progress.batches): | ||
| return ExecutionOutcome.TESTS_FAILED | ||
| if any(batch.status is Status.CANCELLED for batch in self.progress.batches): |
There was a problem hiding this comment.
Let failed jobs outrank a cancelled batch
When a cancelled workflow contains an unconfirmed job whose JUnit artifacts contain failures, _unconfirmed_job_status marks the job as FAILURE, while _finished_batch_progress keeps the batch status as CANCELLED. This outcome calculation only inspects batch statuses, so it returns CANCELLED even though progress.failed > 0; the PR comment's _has_failure check consequently renders the same run as failed while the CLI and run metrics report it as cancelled. Check the collected job failures before selecting the cancelled outcome.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed, though not by letting failed jobs outrank the cancelled batch. A cancelled batch is discarded, so whatever it left unfinished should not count:
- An unconfirmed job in a cancelled run is now reported
cancelledwhatever its artifacts hold. - The run outcome and the PR comment heading now share one rule,
DispatcherProgress.has_failure: a failed batch, or a failed job in a batch that was not cancelled.
A job that completed with failure before the cancellation still counts in jobs.failed, but no longer fails the run, so the CLI, the run metrics and the comment agree.
| if conclusion == WorkflowJobConclusion.CANCELLED: | ||
| return Status.CANCELLED |
There was a problem hiding this comment.
Preserve failing reports from completed cancelled jobs
If tests have already written failing JUnit and the job is then cancelled during the workflow's if: always() report collection or upload, GitHub can return a completed job with conclusion cancelled alongside those reports. The completed-job path in _job_status applies this new mapping directly and never examines the reports, classifying the job as cancelled and dropping the real test failure; by contrast, the newly added unconfirmed-job path correctly lets failed artifacts outrank cancellation. Apply the same failed-report precedence for completed cancelled jobs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this. A cancelled job is discarded: anything it had not finished counts for nothing, including failing reports from steps the cancellation interrupted. Only outcomes that completed before the cancellation are reported.
ca76ba0 to
ff698d0
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
ff698d0 to
1a2021d
Compare
1a2021d to
818845c
Compare
Validation ReportAll 21 validations passed. Show details
|
What does this PR do?
Reports cancelled and timed-out Dispatcher batches and jobs as their own outcomes. GitHub reports a job stopped by
timeout-minutesascancelled, so the Dispatcher tells the two apart itself.Timeouts: a completed job that ran (a runner was assigned,
runner_name), concludedcancelledand lasted at least the test jobs' 120-minute limit timed out. It fails the job, its batch and the run, and counts astimed_outin metrics.TEST_JOB_TIMEOUT_MINUTESis tested against both jobs intest-batch.yml. A shortercancelledjob is a genuine cancellation (Status.CANCELLED). Cancelled jobs that ran now get ajob.durationsample, so timed-out jobs show up in duration charts.Dense outcome counters (
ResultMetricinexecution_metrics.py), identical for batches and jobs:passed,failed,skipped,cancelled,inconclusive,timed_out. Each batch or job emits all six, exactly one of them 1.One owner for outcome counters: the gatherer. It counts each planned job once, at the first progress update showing it finished, or at gathering for jobs never observed finished (from their artifacts). A finished job keeps its outcome whatever happens to its batch later. The runner keeps
job.durationand the completion log.Batch outcome: a genuinely cancelled batch is
cancelled; otherwise a job failure outranks a timeout, which outranks the workflow's own conclusion.Dispatcher cancellation: at shutdown the Dispatcher hands the dispatched batches to
TaskTestGatherer.report_unfinished. On a cancellation, every batch and job without an outcome is countedcancelled, instead ofjobs.incomplete. Other shutdowns keepjobs.incomplete, excluding jobs whose outcome was already counted. Once stopping, the bus no longer delivers progress updates, so a job that finished in the last poll before a cancellation is countedcancelled.Run outcome and PR comment share
DispatcherProgress.has_failure: a failed batch, or a failed job in a batch that was not cancelled. A cancelled batch without failures makes the runcancelled. Cancelled batches and jobs render as🚫. The CLI aborts a cancelled run with "Dispatcher tests were cancelled." (same exit code).dispatcher.batch.idis no longer a metric tag. Batch IDs are plan positions (batch-00,batch-01, ...) and nothing queries metrics by them. The only metrics that needed the tag were thejobs.queuedandjobs.runninggauges, to keep concurrent batches from overwriting each other; the runner now emits their per-platform totals across in-flight batches instead.Cleanup: removed state with no production reader or writer:
BatchFinished.timed_out(never set by the runner) with the gatherer branches andProgressError.TIMED_OUTit fed, and the gatherer's_status_by_batch/_results_by_batchregistries withWorkflowStatus. Tests that read the registries now assert the published progress or emitted metrics.The commit status that
test-batch.ymlposts is unchanged: GitHub commit statuses have nocancelledstate.Motivation
conclusion_to_statusmappedcancelledtoFAILURE, but GitHub usescancelledboth for a genuine cancellation and for a job that hittimeout-minutes. Job 110448952220 ran 120.4 minutes and reportsconclusion: cancelled; only its annotation says "The job has exceeded the maximum execution time of 2h0m0s". The job payload has nothing else that tells them apart, so this uses the duration.The cancellations worth reporting are the Dispatcher's own: once it is cancelled it stops polling, so GitHub never tells it how its batches ended. In the last 7 days, 6,753 of 6,951 incomplete jobs (97%) came from 28 cancelled Dispatcher runs; they are now counted as cancelled.
Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged