Repository navigation
fix: don't orphan ephemeral FSx when the launch fails (#210) - #211
Merged
Merged
Conversation
CRITICAL cost/quota leak. Ephemeral --fsx-create creates the FSx BEFORE RunInstances. On a launch failure (e.g. InsufficientInstanceCapacity — the case lagotto retries on), the filesystem had no instance to own it, and the ttl-reaper keyed ephemeral reclamation on instance termination, so it never got reclaimed. Under lagotto's retry loop this orphaned ~3 x 1.2 TiB FSx per poll → full PERSISTENT_2 quota in ~35 min (~$14.6k/mo). Defense-in-depth: 1. Compensating teardown: both the CLI (cmd/launch.go) and the headless launcher (pkg/launcher/provision.go) delete the just-created ephemeral FSx if RunInstances fails — a failed launch leaves no billable resource (the #193 fail-closed contract). A delete failure is surfaced loudly so a leak is never silent. 2. Reaper safety net (lambda/ttl-reaper): reclaim any spawn:fsx-lifecycle=ephemeral filesystem with no referencing instance for >30min (ephemeralOrphanGrace) — covers 'instance never launched' even if the teardown is missed (crash/delete error). fsxInUse now also counts the spawn:fsx-pending provisioning lease, so a healthy FSx isn't reaped during its ~10-min mount window. Tests: reaper evaluateFSx ephemeral-orphan past/within grace + durable-exempt. All modules build/vet/test clean. Closes #210
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 #210. CRITICAL cost/quota leak.
The bug
Ephemeral
--fsx-createcreates the FSx beforeRunInstances. On a launch failure (e.g.InsufficientInstanceCapacity— exactly what lagotto retries on), the filesystem has no instance to own it, and the ttl-reaper keyed ephemeral reclamation on instance termination — a path never reached when no instance launches. Under lagotto's retry-on-capacity loop this orphaned ~3 × 1.2 TiB filesystems per poll → the full PERSISTENT_2 quota (100,800 GiB / 84 filesystems) in ~35 min, ~$14.6k/mo if left running. It defeats the #193 fail-closed contract: a capacity failure left a 1.2 TiB billable resource behind.Fix — defense-in-depth (issue fixes #2 + #3)
1. Compensating teardown (the primary fix)
Both the CLI (
cmd/launch.go) and the headless launcher (pkg/launcher/provision.go) now delete the just-created ephemeral FSx (config.FSxPending) ifRunInstancesfails. A failed launch leaves no billable resource. A delete failure is surfaced loudly (🛑 … DELETE IT MANUALLY …) so a leak is never silent. Scoped toephemeral— a durable FSx is a deliberate persisted resource.2. Reaper safety net (
lambda/ttl-reaper)evaluateFSxnow reclaims anyspawn:fsx-lifecycle=ephemeralfilesystem with no referencing instance for longer than a 30-min orphan grace (ephemeralOrphanGrace), reasonephemeral-orphan. This covers the "instance never launched" case even if the compensating teardown is missed (crash between create and teardown, or a delete error). Crucially,fsxInUsenow also counts thespawn:fsx-pendingprovisioning lease (not justspawn:fsx-id), so a healthy ephemeral FSx is never reaped during its legitimate ~10-min mount window. Durable filesystems are exempt (they use max-age/deadline, not the short grace).Tests
Reaper:
evaluateFSxephemeral-orphan past-grace (reaped), within-grace (spared), durable-exempt. All three modules (root, launcher, reaper) build / vet / test clean.Follow-up (not in this PR)
lagotto could also avoid re-creating FSx every poll on a capacity-retry (issue fix #4), but the spawn-side fix is the right layer —
--fsx-createwas broken for any failed launch, lagotto or not. Worth a lagotto issue.