Skip to content

Verify spored on fleet members and clean up failed fleet launches (#1305); poll every region in a rolling sweep (#1251) - #1314

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1305-1251-fleet-launch-safety
Oct 26, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1305-1251-fleet-launch-safety

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1305
Fixes #1251

What changed

Multi-instance launches now have the same guarantees v0.145.0 (#1298/#1303) gave a single spawn launch. One helper provides them: fleetGuard in cmd/launch_fleet.go.

  • spored verification per member. Every member gets the single-launch check (verifySporedReadyOn: the heartbeat tag, with SSM as a second signal). Members are verified in parallel, at most 16 at a time, against one shared deadline. A member that waited for a slot gets the rest of the budget, with a floor of 30 s for a final poll. So a fleet waits about as long as one instance, not 5 min per member. A member whose spored never comes up is terminated and reported. Its verified siblings are kept, because each is enforcing its own TTL. --keep-on-error keeps it instead. An explicit --wait-for-ssh=false skips verification, as it does on a single launch.
  • A failure that ends the launch terminates every member launched so far. fleetGuard.finish is deferred over each path's named error. It terminates each recorded member exactly once, unless --keep-on-error.
    • Job arrays / MPI: the Actuator's client is wrapped (recordingLaunchAPI), so the guard knows every instance RunInstances returned. This includes the case where it is ListInstances that failed after the reconcile, which is the case in the issue. The existing job-array-id drain still runs on a failed cohort. What it terminated is marked in the guard, and the guard terminates any member the tag scan missed.
    • Burst: a launch that stops part way terminates the members already launched. Before, it printed them with a spawn array cancel hint.
  • Accounting. In a sweep or rolling queue, an unverified member is a failed parameter set: it is in failures, in state.Failed, and recorded with state: "failed". reconcileSweepState now counts that record as failed. Before, a terminated instance read as completed, so spawn resume would never re-run the set. A plain job array still has to reach --min-viable verified members, and an MPI cluster needs every rank verified. Below that the launch fails and the guard terminates the rest.
  • Reporting. Every path prints spored verified on N of M instance(s); K terminated because spored never came up (ids), plus any kept or failed-to-terminate members.
  • Rolling sweep queue polls only the first launch config's region, so a multi-region sweep never sees other regions' instances finish #1251. The rolling queue groups active members by region and makes one ListInstances per region per tick. A region whose call fails decides nothing about its members that tick. Correction to the issue's stated effect: the old code treated an instance missing from the first region's result as finished (!exists). So a member in another region was not stalled; it was taken as finished at once, and the queue launched past --max-concurrent. The gate asserts both points: the other region is polled, and at most one instance runs at a time.
  • New --keep-on-error on spawn burst and spawn resume. The spawn launch --keep-on-error help now mentions fleets. docs-gen regenerated.

A judgement call to review

The brief says "any failure after RunInstances that makes the command exit non-zero terminates every member". A foreground sweep with one failed row, from RunInstances or from verification, already exited non-zero. The code also documented that its successful rows are deliberately kept ("Parameter sets are independent"). I kept that behaviour. Per-member failures are a partial outcome (fleetPartialError): the command still exits non-zero and names the failed sets, and verified siblings are kept. Only a failure of the launch itself (cohort failure, ListInstances error, burst stopping part way, reconcile error) tears everything down. A partial outcome can only be produced after every surviving member is verified. The same rule applies to a burst member that fails verification. The rolling queue's ctx.Done branch (dead in production today: runLaunch uses context.Background()) waits for in-flight verifications, which terminate their members on the cancelled context. Verified members are kept for spawn resume.

Also: when every active slot of a rolling queue is empty because every launch in it failed, the queue now refills. Before, it hung forever, because nothing was ever removed from an empty active set.

Gates (each watched failing against a compiling revert)

Revert (compiles) Fails
finish never terminates 11 tests: guard, job array ListInstances / reconcile / failed cohort / min-viable / MPI, burst part-way
runArrayCohort without the deferred finish 6 job-array tests
Actuator client not wrapped in the recorder TestJobArrayActuatorRecordsEveryLaunchInTheGuard
failed verification not terminated guard, job array, rolling queue, all-at-once sweep, burst
rolling poll uses cfgs[0].Region TestRollingQueuePollsEveryRegionInTheSweep
reconcileSweepState ignores the failed record TestRollingQueueTerminatesAndFailsAnUnverifiedMember
per-member full budget (no shared deadline) TestFleetVerifySharesOneDeadline
burst without the deferred finish TestBurstStoppedPartWayTerminatesWhatItLaunched
drain results not marked in the guard (double terminate) TestJobArrayFailedCohortTerminatesEachMemberOnce
all-at-once sweep skips verification TestSweepAllAtOnceTerminatesOnlyTheUnverifiedMember
rolling queue skips verification TestRollingQueueTerminatesAndFailsAnUnverifiedMember
terminate not idempotent TestFleetGuardTerminatesAMemberAtMostOnce
partial outcome not passed through 4 tests incl. TestSweepLaunchFailureKeepsVerifiedSiblings

Every test counts Terminate calls through the fleetTerminator seam. None measures wall-clock time. The deadline test injects now.

TestCohortFailureAlwaysDrains (a source-text gate) was updated to the drain's new call text.

Checks

  • make check: everything passes except check-build-tags. That step fails identically on unmodified main in a /private/tmp worktree, which I verified by stashing these changes.
  • make lint: 0 issues in all 10 modules.
  • make check-docs: clean.
  • semgrep scan --config=auto --error .: clean.

No AWS calls were made. No new IAM: Terminate and DescribeInstances are the calls a single launch already makes.

Not covered: detached (Lambda-orchestrated) sweeps. Filed as #1313.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.82646% with 93 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_sweep.go 74.70% 36 Missing and 7 partials ⚠️
cmd/launch_fleet.go 84.57% 19 Missing and 8 partials ⚠️
cmd/launch_jobarray.go 79.76% 15 Missing and 2 partials ⚠️
cmd/resume.go 60.00% 4 Missing ⚠️
cmd/burst.go 90.47% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ch leaves (#1305); poll every region in a rolling sweep (#1251)
@scttfrdmn
scttfrdmn force-pushed the fix/1305-1251-fleet-launch-safety branch from c55e730 to 614a407 Compare October 26, 2026 04:02
@scttfrdmn
scttfrdmn merged commit 1417e57 into main Oct 26, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1305-1251-fleet-launch-safety branch October 26, 2026 04:19
@scttfrdmn scttfrdmn mentioned this pull request Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant