Repository navigation
gce launcher: a job lost to a spot preemption is rerun once its run completes - #217
Conversation
…ompletes
A row finalized `preempted` while it held a job now owes that job's run a rerun
(`rerun: {state: 'owed'}` on the ledger row, from finalRow, so GCE and EC2 alike).
GitHub reruns only completed runs, so every 5 minutes the launcher reads each run
owed one and, once it has completed, settles the row once: when the run failed in
the attempt the lost job ran in and the job failed, it reruns the job
(actions/jobs/<id>/rerun) or, for several lost jobs of one run, the run's failed
jobs (`fired`); otherwise (cancelled, green, already re-attempted, the job not
failed) `dropped` with the reason. The attempt check makes a second rerun of one
attempt impossible across overlapping ticks and restarts. The ledger store lets a
final row take that one write; a refused rerun logs at ERROR, a transient failure
stays owed.
Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
Codex Review Summary: ✅ CompletedThis 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. |
Repeated preemptions would otherwise chain reruns one attempt after another.
A completed run at run_attempt >= 3 settles its owed reruns as dropped
('attempt cap') without reading its jobs.
Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d00249e468
ℹ️ 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 (!owed.length || this.now() - (this.rerunsCheckedAt ?? -Infinity) < RERUN_EVERY_MS) return; | ||
| this.rerunsCheckedAt = this.now(); |
There was a problem hiding this comment.
Preserve the rerun polling timestamp across production ticks
In the deployed launcher, reconcile() in gce/launcher/server.mjs constructs a new Launcher for every tick, so this.rerunsCheckedAt is always undefined when this guard runs. Consequently, every owed run is polled on every scheduled or webhook-triggered tick—potentially every 10 seconds—instead of every five minutes. This adds up to 30 times the intended REST requests while a lost job's run remains active, including repeated requests during transient failures. Keep the timestamp in process-lived dependencies, as the server already does for stockout and provider state; the current cadence test misses this because it reuses one launcher across ticks.
Useful? React with 👍 / 👎.
From the review of 3dc2e4f: - A failed job is rerun only when its runner was lost: a step GitHub never heard end, or the job's end at or after the VM's preemption (logic.mjs lostRunner). A red that reported before its VM was reclaimed settles as dropped 'not a lost runner'. - The per-run read times live in the server's shared state (rerunChecks), since every tick builds a new Launcher; each run owed one is read at most every 5 min, at most 5 runs a tick, least recently read first. - Settling rewrites only the stored row's `rerun`, read fresh, and only while it still owes one for the same job (ledger-store settleRerun); upsert's final-row rule is unchanged again. - A refusal because the run is running again (another launcher's rerun won) stays owed; a later read settles it from the attempt. - A repo no longer in gce.json, or a public repo's run for an event the pool does not serve, settles as dropped 'not served'. Deferred items are recorded in #218 and #201. Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
…time budget per sweep From the second review of a3cdcd1: - lostRunner: a step that concluded failure before the VM's preemption makes the job a real red, even when the preemption cut a later step (an upload) short. A failed step that ended at or after the preemption is the guest's shutdown failing it (sandbox run 38927837115), and still counts as lost. - The sweep starts no GitHub or ledger call past 30 s in a tick; what it leaves stays owed, its run read first next tick. The writes recording a rerun just sent still run. Two more deferred items are on #218. Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
…runner Only a failed step whose completed_at is before the preemption makes the job a real red; one with no time leaves the unfinished-step and late-end signals to decide. Deferred items from the third review are on #218. Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
Why
When GCE preempts a spot VM mid-job, GitHub fails the job and a human reruns it (e.g. MAWS run 44468141412,
static-localonci-kit-gce-ht8ps9vecf, preempted 52 s after creation; about 9 a week). The launcher already finalizes such a rowpreemptedwith the job it held; it now reruns that job itself.Design
finalRowmarks a row endingpreemptedwith a jobrerun: {state: 'owed'}. Every end goes through it, so GCE preemptions and EC2Server.SpotInstanceTerminationare both covered. The ledger row is the persisted state, so it survives a restart. Theendcolumn readspreempted, rerun owed.settleRerunsreads each run that is owed a rerun. That is one conditionalGET runper run, nothing for rows that owe nothing. A run still in progress is left alone, because GitHub refuses reruns before a run completes.GET actions/jobs/<id>). It reruns only if the job'srun_attemptequals the run's, the run concludedfailureand the job concludedfailure:POST actions/jobs/<id>/rerun, which reruns that job plus the jobs that need it and leaves genuine red jobs alone;POST runs/<id>/rerun-failed-jobs.The row then settles to
fired(with the attempt and how) ordropped(with the reason: cancelled, success, already re-attempted, the job didn't fail).rerun-refused). A 5xx, network error or rate limit leaves the rerun owed. Rows leave the ledger's 26 h window, so a rerun that is never settled ages out.settlesRerun). Every other rule that keeps a row from moving back is unchanged.Credential
The launcher uses the
ci-kit-runnersApp installation token unscoped (gce/launcher/github.mjs, noscope). The App's permissions (GET /apps/ci-kit-runners) includeactions: write, and the design doc records that the installation held it on 2026-10-17. Nothing to widen.Tests
New
test/gce/launcher-rerun.test.mjsruns againstfake-world.mjs, which now has run/job reads and reruns that GitHub-style refuse a run still in progress. It covers:node --test test/gce/*.test.mjs: 531 pass.Not deployed.
Since review (a3cdcd1)
Some of the design above has changed:
not a lost runner.rerunChecks), because the server builds a new Launcher every tick.attempt cap).ledger.settleRerunre-reads the stored row and changes only itsrerun, and only while that row still owes one for the same job.upsert's rule that a final row is never rewritten is unchanged.already runningrefusal (another launcher's rerun won) stays owed, and a later read settles it from the run's attempt.not served.Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)