Repository navigation
fix(ci): sweep open PR heads for the infrastructure-retry watchdog (#15139) - #15399
Merged
Merged
Conversation
…15139) ci_dispatch_retry.py only ever classified one --sha, and the workflow step that drives it runs exclusively on non-pull_request events, where github.event.pull_request.head.sha never resolves -- HEAD_SHA always fell back to github.sha, the base branch tip. The sweep never reached the red PR head it was built to repair. Follow ci_dispatch_watchdog.py --check dispatch's established pattern instead: list every open PR against the base branch and classify each head, with the re-run budget spent across the whole flattened sweep (not reset per PR) so widening from one sha to N PRs cannot turn one outage into a rate-limit exhaustion.
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
…sue-15139-retry-sweep
4 tasks
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.
Thinking Path
PR #15396 added
pipeline-scripts/ci_dispatch_retry.pyto re-dispatch red checks that were caused by an empty runner pool rather than a real test failure. Re-verified against the merged tree atdfa525dc19:HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}is only evaluated in the "Re-dispatch infrastructure-caused reds" step, which is gatedif: github.event_name != 'pull_request'.schedule,push,workflow_dispatch),github.event.pull_requestis unset, soHEAD_SHAalways fell back togithub.sha— the base branch tip, never a red PR's head.ci_dispatch_retry.py'srun(sha, dry_run)classified exactly that one sha and had zero references toopen_pull_requests.Net effect confirmed: the scheduled sweep re-dispatched checks for
Dev_new_gui's own tip on every run and never touched an actual open PR. The siblingci_dispatch_watchdog.py --check dispatchsweep already solves the "reach every open PR" problem viaapi.open_pull_requests(base)+collect_heads, so this PR reuses that path instead of inventing a second one.What Changed
pipeline-scripts/ci_dispatch_retry.py:run()now lists every open PR against the base branch (WATCHDOG_BASE_BRANCH, defaultDev_new_gui, imported fromci_dispatch_watchdog.DEFAULT_BASE_BRANCH), classifies each head via the existingclassify_commit, and flattens the infrastructure-caused reds from every PR into one candidate list before callingredispatch(). The--shaCLI flag is gone;--baseis optional and defaults to the env var / constant.budget_blocked(unreadable/low REST rate-limit) andcapacity_blocked(in-progress ceiling) are each checked exactly once, before any PR is listed, so a busy queue or an unreadable rate limit stops the sweep before it spends anything.redispatch()'smax_rerunsbudget walks the single flattened candidate list built across ALL open PRs — once it is spent partway through PR Docs improvements #1's reds, PR Docs improvements #2 (and beyond) are never even reached for re-dispatch, because the counter is never reset per PR.max_attempts(one retry per run) and the per-red job resolution are unchanged..github/workflows/ci-dispatch-watchdog.yml: the "Re-dispatch infrastructure-caused reds" step drops the now-unusedHEAD_SHAcomputation and passesWATCHDOG_BASE_BRANCH: Dev_new_guiinstead (matching the "Sweep open PRs" step above it). Event gating (!= 'pull_request') and step ordering (after the self-modification guard) are unchanged, so a PR's own unreviewed copy of this code still never runs withactions: write.repo_tests/ci_dispatch_retry_test.py(new file —ci_dispatch_watchdog_test.pyis at its frozen line ceiling per instructions, so this doesn't touch it): 5 tests with a fakeGitHubApi.requesttransport, each proven by mutation (see below).Verification
python3 -m pytest repo_tests/ci_dispatch_retry_test.py -q→ 5 passed.repo_tests/ci_dispatch_watchdog_test.py(113 tests, untouched) andrepo_tests/python_file_size_ratchet_test.py(31 tests) still pass. Pre-push hook ran the new test file and passed. All functions in the changed module are ≤30 lines (verified viaast); file is 276 lines, well under the 600-line cap.Mutation evidence (defect reintroduced → test fails → reverted,
diffagainst saved-clean copy confirmed empty after each):test_budget_exhausted_mid_sweep_stops_before_the_next_prif done >= limits["max_reruns"]:→if False:(budget check removed)test_capacity_at_ceiling_declines_the_sweepif count >= ceiling:→if count > ceiling:test_unreadable_rate_limit_declines_rather_than_proceedingrate_limit_remaining'sstatus != 200fallback:return -1→return 999999test_run_attempt_two_or_more_is_left_red_not_retriedif attempt >= limits["max_attempts"]:→if attempt > limits["max_attempts"]:test_sweep_reaches_an_open_prs_head_sha_not_a_base_tipheads = collect_heads(...)→heads = [](reintroducing the pre-fix single-sha bug)Model Used
Claude Sonnet 5
Closes #15139