Skip to content

ci: stuck-run watchdog (report always, cancel only superseded runs); timeout-minutes on every non-release job - #1276

Merged
bpalermo merged 2 commits into
mainfrom
upgrade/ci-stuck-run-watchdog
Oct 5, 2026
Merged

bpalermo merged 2 commits into
mainfrom
upgrade/ci-stuck-run-watchdog

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Stack 1/3 (#1276 → #1278 → #1279).

Problem (confirmed)

publish.yaml (group publish-main), proxy-release.yml (proxy-release-main) and pages.yaml (pages) use cancel-in-progress: false. GitHub keeps at most one pending run per group. So when one run's job never gets a runner, it blocks every later run of that workflow, and nothing flags it.

Today's evidence (gh run list):

  • publish: 37322742027 (b1dc1c04) was created at 14:11 and only ended, cancelled, at 19:19. In between, seven newer publishes were each replaced as cancelled (14:27 → 17:38). Only df3a1136 published, at 19:29.
  • pages: every run from 2026-10-04 22:31 through 2026-10-05 16:25 ended cancelled. 37344777943 waited 2.5 h before its build job started at 19:28.
  • Still queued now: 34723047990, a proxy pull_request run, has been queued since 2026-09-12 with zero jobs. Its branch chore/proxy-image-bump-733802b no longer exists.
  • GitHub status right now: Actions is in degraded_performance ("Incident with Actions", opened 19:11Z). This PR's own runs sat queued for a while because of it.

Watchdog

.github/workflows/stuck-runs.yaml runs scripts/stuck-runs.sh.

Triggers.

  • Cron 7,37 * * * *: acts.
  • workflow_dispatch: a dry run unless dry_run=false; threshold_minutes is an input.
  • pull_request touching the watchdog or its script: always a dry run, against the live run list. This trigger is also what lets GitHub register the workflow so it can be dispatched from a branch.

Stuck, using a 60-minute threshold (publish and proxy-release take about 10 minutes):

  • the run is pending / waiting / requested for longer than the threshold, measured from run_started_at; or
  • the run is queued / in_progress and has a job sitting queued for longer than the threshold, measured from the job's creation. A run that waited its turn behind another one and then got a runner quickly is therefore not stuck. This was the pages run's situation at 19:35.
  • the run is queued with no jobs at all.

Reported: every stuck run, on one rolling issue, CI: workflow runs stuck before they started:

  • found by exact title, never duplicated;
  • commented on only when the set of stuck runs changes (one comment per change, not one every 30 minutes);
  • closed once nothing is stuck.

Each tick also writes a ::warning:: and a job summary.

Cancelled only if superseded. All of these must hold:

  • the event is push / pull_request;
  • it is the run's first attempt (a re-run is how the runbook republishes an old commit);
  • the run is not from a fork;
  • and either:
    • the branch is gone, or
    • the commit is no longer the branch head and a newer run of the same workflow on that branch is queued, running, or succeeded.

The newer-run condition is not in the brief. I added it after the dry run against live data: pages is path-filtered, and main had moved past 28b2680a with no newer pages run coming, so cancelling that run would have dropped the deploy. The watchdog never cancels the head's own run, a re-run, a schedule or dispatch run, a fork run, or a run whose head lookup failed. Those are reported only, with the manual remedy in the runbook.

Permissions: contents: read at the workflow level. The job adds actions: write (list and cancel runs) and issues: write.

What it would do right now (local collect + decide against the live API, 19:46Z):

cancel  34723047990  proxy  pull_request  chore/proxy-image-bump-733802b  queued  32944m  superseded: branch chore/proxy-image-bump-733802b no longer exists

I have not cancelled it. That is yours to decide, or the first scheduled tick after merge will do it.

Test: //scripts:stuck_runs_test, hermetic and in bazel test //....

  • 10 canned-API-JSON fixtures:
    • the 10-05 publish shape;
    • pages with no newer run;
    • a newer run that failed, and one that succeeded;
    • a deleted branch;
    • the head's own run;
    • re-run / schedule / dispatch / fork / unknown head;
    • not-stuck shapes;
    • an in-progress run with a queued job;
    • empty.
  • run end to end through a fake gh:
    • --dry-run writes nothing;
    • a real run cancels exactly the superseded run and opens the issue;
    • the same set again adds no comment;
    • a different set adds one comment;
    • clear closes the issue.
  • Mutation checks. Making "no newer run" cancel, and making --dry-run act, each turn the test red.

jq for the test comes from jq.bzl 0.6.0. It was already in the module graph via aspect_rules_lint; here it becomes a direct bazel_dep plus use_repo(jq_toolchains). MODULE.bazel.lock is unchanged.

timeout-minutes

A timeout does not rescue a queued job, which is why the watchdog exists. It does stop a hung running job.

Jobs that had no timeout (values sized from the slowest successful run among the last 100 of each workflow):

workflow jobs
ci.yaml changes 10, diff 30, chart-version-bump 10, deps-audit 20, shell 30, format 20, envoy-api-parity 10, proxy-pin 15, test 90 (slowest 31), race 60, netns 30, integration 45, e2e 45, ci 5
main.yaml diff 30, test 90 (slowest 35), refresh-pin-prs 15
pages.yaml build 30, deploy 15
proxy.yml changes 10, shell 30, test 120 (slowest 13; a cold Envoy compile is far longer), proxy 5
quay-smoke.yaml smoke 30
e2e.yaml report-failure 10 (the other e2e jobs already had one)

Still without a timeout, left untouched as instructed: publish.yaml publish, and proxy-release.yml build-push, manifest, sign and bump-chart.

Proof

  • bazel test //scripts:stuck_runs_test //e2e:kind_pin_test //website:site_test: pass.
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //scripts:all: clean.
  • make format-check: clean.
  • actionlint 1.7.12: no new findings. The 20 older findings are fixed in ci: enforce actionlint (pinned, repo ShellCheck) and fix its 20 findings #1278.
  • Dry-run dispatch: see the comment below once the runs leave the queue.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

@bpalermo
bpalermo added this pull request to stack #1280 October 5, 2026 20:02
@bpalermo bpalermo changed the title upgrade/ci stuck run watchdog ci: stuck-run watchdog (report always, cancel only superseded runs); timeout-minutes on every non-release job Oct 5, 2026
@bpalermo
bpalermo marked this pull request as ready for review October 5, 2026 20:04
bpalermo and others added 2 commits October 5, 2026 19:05
publish.yaml, proxy-release.yml and pages.yaml serialise with
cancel-in-progress: false, and GitHub keeps one pending run per group, so a
run whose job never gets a runner blocks the group silently. On 2026-10-05 a
publish run (b1dc1c0) sat queued for five hours and a pages run queued since
2026-10-02 blocked the website for three days.

.github/workflows/stuck-runs.yaml (every 30 min + workflow_dispatch, dry run
by default on dispatch) runs scripts/stuck-runs.sh: a run pending/waiting/
requested, or with a job queued, for more than 60 minutes is reported on one
rolling issue (commented only when the stuck set changes, closed when clear),
and cancelled only when it is superseded: push/pull_request, first attempt,
same repository, and its branch is gone or its commit is not the branch head
AND a newer run of the same workflow on that branch is queued, running or
succeeded. The head's own run is never cancelled. Job permissions: contents
read, actions write, issues write.

//scripts:stuck_runs_test pins the decisions on canned API JSON (10 fixtures,
including the 10-05 publish incident) and drives `run` through a fake gh:
--dry-run writes nothing, a real run cancels exactly the superseded run.
jq for it comes from jq.bzl (already in the module graph), made visible as a
direct bazel_dep.

Also: timeout-minutes on every job that lacked one outside the release
workflows (ci.yaml x14, main.yaml x3, pages.yaml x2, proxy.yml x4,
quay-smoke.yaml, e2e.yaml report-failure), sized from the last 100 runs.
publish.yaml and proxy-release.yml still lack them and are left untouched.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
A new workflow can only be dispatched once GitHub has registered it, which
for a file that exists only on a branch means after it has run there. The
pull_request trigger (paths: the workflow and its script) is also the self-
test: a change runs the watchdog against the live run list, always as a dry
run. Concurrency is per ref so a pull request never cancels main's tick.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the upgrade/ci-stuck-run-watchdog branch from e0ac885 to a7904d9 Compare October 5, 2026 22:05
@bpalermo
bpalermo merged commit 308f8b3 into main Oct 5, 2026
26 checks passed
@bpalermo
bpalermo deleted the upgrade/ci-stuck-run-watchdog branch October 5, 2026 22:39
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.

1 participant