Repository navigation
fix: Provision tears down instance on post-launch failure (#220) - #230
Merged
Merged
Conversation
Root cause of #220 (verified live, not the reported pre-launch-ordering hypothesis): when RunInstances SUCCEEDS but a post-launch step fails (ephemeral FSx setup), Provision returned (nil, err) WITHOUT terminating the now-running instance. That orphans a billable instance — and under lagotto's per-AZ retry loop, the caller treats it as a failed attempt and launches ANOTHER one, orphaning one instance (+ any FSx created before the sub-failure) per AZ. That matches the observed '3 orphans per capacity burst, ~1 per AZ' far better than the pre-#213 ordering (which #213 already fixed and which a live repro confirmed creates zero FSx on a RunInstances failure). Fix: - On any post-launch failure, terminate the just-launched instance so a partial provision leaves nothing billable (the #193 fail-closed contract now extends past RunInstances). Verified live in 942542972736/us-west-2: the scenario that orphaned a t3.micro now auto-terminates it; leak-check clean. - New launcher.ErrPostLaunch sentinel wrapping these failures, so AZ/region-retry callers (lagotto launchAcrossAZs) can treat them as terminal instead of re-launching into the same downstream failure. Tests: TestProvision_NoFSxOrphanOnLaunchFailure (zero FSx on RunInstances failure, substrate-backed + non-vacuous) + the live before/after proof. Refs #220, #210, #213.
scttfrdmn
force-pushed
the
fix/220-provision-post-launch-cleanup
branch
from
June 24, 2026 15:36
501453d to
56786c8
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…odule The lambda/dns-updater submodule still pinned x/net v0.52.0, which newly-published HIGH CVEs (CVE-2026-25680/25681/27136/33814/39821/42502/42506 — HTML-parse DoS, HTTP/2 DoS, IDNA priv-esc) now flag, failing the Trivy gate. The main module is already on v0.55.0; this brings the submodule in line. Incidental to #220 (the fix is in pkg/launcher) but bundled to keep this PR's CI green.
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.
Closes #220.
The real root cause (not the reported one)
I traced #220 exhaustively — static (against the v0.61.0/v0.62.0 tags) and live in 942542972736/us-west-2. The issue hypothesized a pre-launch FSx-ordering regression ("CreateFileSystem per-AZ before RunInstances"). That is not what v0.62.0 does — #213 genuinely reordered create-to-after-launch, and a live repro confirmed a
RunInstancesfailure creates zero FSx.The actual bug is post-launch abandonment:
RunInstancessucceeds → instance is running.Provisionreturned(nil, err)— without terminating the running instance.launchAcrossAZs), the caller treats the error as a failed attempt and launches another instance in the next AZ, orphaning one instance (+ any FSx created before the sub-failure) per AZ — exactly the "3 orphans per capacity burst, ~1 per AZ" pattern reported.Live proof (before → after), cheap t3.micro, cleaned up
Forced a real post-launch failure (valid launch, invalid FSx capacity):
Provisionerrored; leak-check found instancei-0f5c…running (orphaned) — terminated manually.post-launch provisioning failure: FSx setup failed, terminated instance i-0fe9… to avoid a leak; leak-check clean (instanceterminated, zero FSx).Fix
Provisionterminates the just-launched instance on any post-launch failure — a partial provision leaves nothing billable (FSx auto-create: explicit lifecycle contract (ephemeral|durable), fail-closed, + canonical docs #193 fail-closed contract, extended past RunInstances). The existing FSx-create function already deletes a created-then-untaggable FSx; the two cleanup paths compose.launcher.ErrPostLaunchsentinel wrapping these failures, so AZ/region-retry callers can classify them terminal (the launch worked — retrying churns launch+terminate). lagotto'sClassifyFailurewill key on this (companion lagotto PR).Tests
TestProvision_NoFSxOrphanOnLaunchFailure— substrate-backed, verified non-vacuous (substrate does track FSx creates): aRunInstancesfailure creates zero FSx.make checkclean.Note on the reaper
The deployed ttl-reaper would eventually catch these (ephemeral-orphan net), but it doesn't run in end-user accounts (lagotto#29) — so for the beta accounts hitting this,
Provision's own cleanup is the only backstop. That's why the fix belongs here.