vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Stop a superseded build instead of leaving it to finish
3031e35772b7d5498c3cb1427424169889632ab5 · Keenan Nemetz · 11d ago · parent 3ae0f579
Stop a superseded build instead of leaving it to finish A push that replaced a branch tip canceled the older commit's queued runs but left a running one alone. With long jobs and a single-slot runner, the runner kept building a commit that was no longer on the branch while the new tip's jobs waited. A rewrite can leave that commit unreachable entirely: on rack's seam-joint branch the old tip ran for 27m38s after the branch had moved, with 12 jobs queued behind it. CancelSuperseded now asks a running run for the replaced commit to stop too: it sets cancel_requested and leaves the lease, which is the path a manual cancel already uses. The runner stops at its next heartbeat, RecordAttempt keeps the result canceled rather than failed, and RequeueExpired already cancels a requested stop whose runner vanished instead of making it leasable again. The stale-deploy test moves its second commit with a fetch instead of a push: a push now stops the running build, and the deploy guard is what covers the window before the runner sees the request. It then pushes a third commit so the fresh-build half of the test still runs. Verified with go test ./server/ and vole workflow run verify.
server/reconcile_test.go +28
| @@ -218,6 +218,34 @@ func TestANewerTipCancelsTheQueuedBuildOfTheOlderOne(t *testing.T) { | |||
| 218 | 218 | } | |
| 219 | 219 | } | |
| 220 | 220 | ||
| 221 | // A run the old tip already gave to a runner is asked to stop: the commit it is | ||
| 222 | // building is no longer what the ref names, so its result cannot count for the | ||
| 223 | // branch and the slot belongs to the new tip. | ||
| 224 | func TestANewerTipStopsTheRunningBuildOfTheOlderOne(t *testing.T) { | ||
| 225 | t.Parallel() | ||
| 226 | h := newReconcileHarness(t) | ||
| 227 | first := h.commit(t, "refs/heads/main", testWorkflow) | ||
| 228 | h.s.reconcileRefs() | ||
| 229 | leased, err := h.runs.Lease(runs.LeaseRequest{ | ||
| 230 | Owner: "runner", Repos: []string{"demo"}, TTL: time.Minute, | ||
| 231 | }, time.Now().UTC()) | ||
| 232 | if err != nil || leased == nil || leased.SHA != first { | ||
| 233 | t.Fatalf("lease = %+v, %v; want the first tip", leased, err) | ||
| 234 | } | ||
| 235 | |||
| 236 | h.commit(t, "refs/heads/main", testWorkflow) | ||
| 237 | h.s.reconcileRefs() | ||
| 238 | |||
| 239 | got, err := h.runs.Get(leased.ID) | ||
| 240 | if err != nil { | ||
| 241 | t.Fatal(err) | ||
| 242 | } | ||
| 243 | if got.Status != runs.StatusRunning || !got.CancelRequested { | ||
| 244 | t.Fatalf("the run for the replaced tip is %q (cancel requested %t), want running and asked to stop", | ||
| 245 | got.Status, got.CancelRequested) | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 221 | 249 | // A rename must carry the queue with it. Rows are keyed by repository name, so a | |
| 222 | 250 | // stranded job is one no runner is ever told about — the lease filters by the names an | |
| 223 | 251 | // account may run, and the old name no longer exists — and a stranded cursor makes the | |