docs/release/backport-tasks/failed-ci.md says to defer the culprit with run --defer --push. When the culprit was all the batch carried, the push stopped with "close batch pull request #N instead", and closing it by hand left nothing that said why: once closed, the deferred original was simply missing. The run now closes the batch itself, and does every write while the pull request is open: the report, then the body, whose record keeps the deferrals and says the batch is closing, at the head the rebuild started from. The close and the deletion of the branch go only while GitHub and the remote still show that head, and the deletion is leased on it. A close that stops part way is finished by the next run --push, before anything else, and by no other command; a head the close did not freeze is refused, never adopted. The run that finishes it stops there, and fails when it was asked for --defer, since no open batch is left to defer on. Recovery never writes the closed pull request. A same-day batch that reuses the branch name and fails to open its pull request leaves a branch the next run names for a person to delete. Assisted-By: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
3.7 KiB
Attribute a failed batch CI
CI on the batch pull request runs the line's build and tests against every original the batch carries at once. When a check fails, this task finds the original the failure comes from and takes it out of the batch, so the rest can merge; the original goes to the next batch with the reason recorded. Read the rules for every task first.
Inputs
- The open batch pull request for the line and its failing checks:
gh pr checks <batch>, and the log of each failing job,gh run view <run id> --log-failed. - The originals the batch carries, one unit each on its first-parent line:
git log --first-parent --reverse --format='%h %s' origin/<line>..origin/backport-batch/<line>-<yyyymmdd>. A merged pull request's unit is a merge whose message is the original's merge message, naming its number, and whoseBackported-from:trailer names its merge commit onmain; its commits aregit log --reverse --format='%h %an %s' <unit>^1..<unit>^2. A squash-merged one is one commit whose subject ends in its number. The files a unit changes aregit diff --name-only <unit>^1 <unit>. - The line's own CI on its head,
gh run list --branch <line>, to tell a failure the batch brought from one the line already had.
Output
The batch rebuilt without the culprits, by one backport-batch run --defer with --push, which records each culprit and the reason in the batch pull request. Nothing else: no commit by hand, no revert, no edit to the batch branch.
Steps
- Read the failing jobs and name what fails: the job, the package or test, and the first error.
- When the same job fails the same way on the line's head, or the failure is the runner's (a timeout pulling an image, a lost runner, a registry error), the batch did not cause it: defer nothing, and comment on the batch pull request with the job and the line's run that shows the same failure.
- Otherwise pin it on originals by their files: the originals that change the failing package, chart or test, or what it builds from. Take the fewest that explain the failure; when no original's files reach the failure, or every original's do, the culprit cannot be pinned from files alone: read the failure further before deferring anything.
- Write the reason as one line naming the job and the failure, for example
e2e-apps: postgres never becomes Ready.
Check before pushing
/tmp/backport-batch run --line <line> --defer N[,N] --reason "<job>: <failure>"
It rebuilds the branch locally without those originals and prints the new body, exiting 0. It exits 2 and names the original when dropping one leaves a later commit that no longer applies; add that one to --defer only when its files reach the failure too, otherwise comment on the batch pull request naming it and stop. Then publish the same command with --push:
/tmp/backport-batch run --line <line> --defer N[,N] --reason "<job>: <failure>" --push
It replaces the batch branch only if nobody pushed onto it since the rebuild read it, and updates the pull request body. CI runs again on the new head; if it fails again on another original, repeat from step 1.
When the culprits are everything the batch carries, there is no branch left to push: the body printed without --push says the batch is closing, and --push records the deferrals in the batch pull request, closes it and deletes its branch, still only if nobody pushed onto it since. The next batch tries them again. If it stops part way, the next run --push on the line finishes the close, and says so.
Never
- Defer an original the failure does not reach, to make the batch green by taking out more than the culprit.
- Push the rebuilt branch any other way, or push to it by hand.