Skip to content

--fsx-lifecycle ephemeral did not reap the filesystem when the instance terminated (1.2 TiB left AVAILABLE and billing) #613

Closed

Description

@scttfrdmn

What happened

Launched with --fsx-create --fsx-lifecycle ephemeral, whose help text states the filesystem is "reaped when this instance terminates". The instance terminated; the filesystem did not. It sat at AVAILABLE, 1200 GiB, and had to be deleted by hand.

spawn launch fsxcmp --region us-west-2 --instance-type c8g.4xlarge \
  --fsx-create --fsx-s3-bucket cookbook-942542972736-us-west-2 \
  --fsx-import-path s3://cookbook-942542972736-us-west-2/inputs/bwa-real \
  --fsx-storage-capacity 1200 --fsx-throughput 125 \
  --fsx-lifecycle ephemeral --fsx-mount-point /mnt/fsx \
  --command '...' --ttl 75m --cost-limit 2.50 --on-complete terminate

Sequence, with the caveat stated up front:

  1. Instance i-02101b630f2031e2f launched; filesystem fs-0d0d29cb9e4be40df created (1200 GiB).
  2. The instance's --command failed immediately (separate issue), so the instance idled.
  3. spawn terminate fsxcmp -y → instance terminated (confirmed via describe-instances).
  4. aws fsx describe-file-systems still showed fs-0d0d29cb9e4be40df — first CREATING, then AVAILABLE — with no instance attached.
  5. spawn fsx list showed it too, still tagged with stack name fsxcmp.
  6. spawn fsx delete fs-0d0d29cb9e4be40df worked and reported deletion initiated.

The caveat, because it may be the trigger: I terminated the instance while the filesystem was still in CREATING. It is plausible the reaper only fires on a normal completion path, or refuses to act on a filesystem that is not yet AVAILABLE and then never revisits it. If so, the bug is the missing retry rather than the reap itself — an ephemeral filesystem that finishes creating after its instance is gone has no remaining owner and nothing will ever delete it.

Why it matters more than the usual cleanup nit

spawn fsx list still knew the stack name, so the association was not lost — only unacted on. And the spend is not small or self-limiting:

  • 1200 GiB is the minimum FSx Lustre size, ~$0.145/GiB-month ≈ $174/month for something the user believes is ephemeral.
  • --cost-limit cannot catch it. Its own help says "compute cost only", so a 1.2 TiB filesystem is invisible to the cap that a user reasonably assumes bounds the launch. --estimate-only likewise reported only the instance (TTL cost: $0.80) and said nothing about the filesystem it was about to create.
  • It is silent. Nothing in the terminate output mentions the filesystem, so the natural assumption after spawn terminate is that ephemeral did its job.

Suggested

  1. Reap ephemeral filesystems whenever their instance is gone, not only on the happy path — a reconcile pass that deletes any ephemeral-tagged filesystem whose instance no longer exists would cover the CREATING race and any other early exit.
  2. Say something on terminate: spawn terminate printing "also deleting ephemeral filesystem fs-… (1200 GiB)" — or a warning when it can't — would make the leak visible at the moment the user is watching.
  3. Include FSx in --estimate-only and, if possible, in --cost-limit. A flag that creates a $174/month resource should surface it in the cost preview; at minimum the estimate should name it even if the cap can only track compute.

Found while measuring copy-vs-mount data paths (FSx Lustre vs EFS vs lith vs aws s3 cp) for the scientific-codes-cookbook. spawn 0.111.1, us-west-2.

Activity

  1. scttfrdmn commented on Sep 26, 2026

    @scttfrdmn
    ContributorAuthor

    Investigated. Your caveat was a good instinct but the CREATING race isn't the cause — the code already handles it. There are three separate true findings here, and the one that caused this leak is operational.

    1. The reaper never looks at your account (this is the actual cause)

    The ephemeral-FSx reclamation you were relying on lives in the ttl-reaper Lambda, and it already covers exactly your scenario:

    So a CREATING filesystem whose instance vanished is exactly what that net is for. It didn't fire because the reaper doesn't scan account 942542972736:

    REAPER_ROLE_ARNS = arn:aws:iam::435415984226:role/spawn-ttl-reaper-ec2   # only 435415984226
    REAPER_SCAN_SELF = false                                                 # not even its own account
    REAPER_DRY_RUN   = false                                                 # it IS enforcing
    REAPER_REGIONS   = ...,us-west-2,...                                     # region coverage is fine
    

    resolveAccounts builds its account list statically from those two env vars. Enforce mode ✅, region ✅, code ✅ — account coverage ❌. The single deployed reaper (spawn-ttl-reaper-production, infra account, us-east-1) has never looked at the account you launch in.

    This is bigger than FSx. The reaper is the out-of-band backstop for the whole "everything dies eventually" invariant. In 942542972736 there is no backstop for any orphan class — past-TTL instances included. spored is the primary enforcer and normally works, which is why this hasn't bitten harder; your 1.2 TiB filesystem is just the first orphan expensive enough to notice.

    2. --fsx-lifecycle ephemeral's help text overpromises

    It says "reaped when this instance terminates". But cmd/terminate.go contains no FSx handling at all — nothing reaps at terminate time. The reclamation is entirely asynchronous, best-effort, grace-delayed, and contingent on reaper infrastructure covering your account. Your assumption after spawn terminate was the only reasonable reading of that text; the text is wrong. Your ask 2 is the right fix, and I'd add correcting the flag help.

    3. FSx really is invisible to the cost controls

    Confirmed: --cost-limit is compute-only by its own admission, and --estimate-only never mentions the filesystem it's about to create. A flag that provisions a ~$174/month minimum-size resource should name it in the preview even if the cap can only track compute. Ask 3 stands.

    What I'd do

    1. Extend reaper coverage to 942542972736 — needs a spawn-ttl-reaper-ec2 role there trusting the reaper with ExternalId=spawn-ttl-reaper, then its ARN added to REAPER_ROLE_ARNS. This is the fix that actually closes the leak, and it closes it for every orphan class, not just FSx.
    2. Make the promise honest: correct the --fsx-lifecycle help, and have spawn terminate report the associated ephemeral filesystem — including when it can't confirm reclamation.
    3. Surface FSx in --estimate-only (and note the cap's compute-only scope at the point of use, not only in flag help).

    Worth saying plainly: nothing here was a code defect in the reap logic. The leak happened because the safety net isn't installed where you work, and the CLI told you it was automatic. Thanks for the precise sequence — the CREATING detail is what let me rule the race in and then back out.

  2. scttfrdmn commented on Oct 4, 2026

    @scttfrdmn
    ContributorAuthor

    Root cause identified: the reaper has no coverage of that account at all

    Found while investigating #652. The production reaper's own log line settles it:

    ttl-reaper done in 12.23s: {Accounts:1 Scanned:0 ... FSxScanned:0 FSxExpired:0 FSxReaped:0 ...}
    

    Accounts:1 — the reaper scans exactly one account, 435415984226, which is the only entry in REAPER_ROLE_ARNS. The filesystem in this report was in 942542972736. The reaper never had visibility into it, so the #210 ephemeral-orphan net could not have caught the orphan no matter how it behaved.

    FSxScanned:0 on every invocation confirms the FSx path is not failing — it is never reaching that account's filesystems in the first place.

    Why that account can't simply be added

    942542972736 is the account whose organization forbids external-account trust. Adding it to REAPER_ROLE_ARNS requires deploying ttl-reaper-cross-account-role.yaml there, i.e. a role trusting the infra account — which is exactly what produced an automated security finding in 12 minutes, with the org's tooling flipping the trust policy to Deny. Least-privilege didn't help; the objection was the external principal itself.

    So this is not a configuration oversight. It is the structural gap that #624 (make coverage detectable) and #625 (spawn reaper deploy — a supported in-account reaper needing no cross-account trust) exist to close. Both have shipped. The remaining step for this account is to actually run spawn reaper deploy in it, which gives it a backstop without any trust relationship.

    What that means for this issue

    The ephemeral-FSx reaping logic is not demonstrated broken by this report — it was never exercised. Two things are worth separating:

    1. spored could not delete the filesystem itself. It dies with the instance, so anything outliving the instance is by definition out of its reach — that part is working as designed, and is why the reaper backstop exists.
    2. No backstop existed in that account. That is the actual defect, now fixable via No supported way to run the TTL reaper in your own account, so governed orgs can't have reaper coverage at all #625.

    I'd suggest this issue stays open until spawn reaper deploy has been run in 942542972736 and a deliberate ephemeral-FSx orphan is confirmed reaped there. That is the test that would actually prove the #210 net works, and it is cheap to run.

    Unrelated discrepancy noted while here

    deployment/cloudformation/ttl-reaper-cross-account-role.yaml tag-conditions fsx:DeleteFileSystem on aws:ResourceTag/spawn:managed, while pkg/reaperiam's scan-self policy states FSx cannot be tag-conditioned for that action and relies on the reaper's in-code guard instead. One of those is wrong. It is not implicated here (the call was never made), but if the condition is ineffective the cross-account role is less constrained than it reads, and if it is effective then the scan-self comment is wrong and that policy is looser than it needs to be. Folding the reconciliation into #652, which is already extending the drift gate to cover both roles.

  3. scttfrdmn commented on Oct 5, 2026

    @scttfrdmn
    ContributorAuthor

    Re-verified against a built binary today — all three code findings are shipped

    Picking this up to close out, I re-checked each of the three rather than trusting the earlier write-up.

    Finding 3 (FSx invisible in the cost preview) — fixed. Your original launch, as an estimate:

    $ spawn launch e613check --region us-west-2 --instance-type c8g.4xlarge \
        --fsx-create --fsx-lifecycle ephemeral --fsx-s3-bucket … \
        --fsx-storage-capacity 1200 --fsx-throughput 125 --ttl 75m --estimate-only
    
    💰 Cost estimate for c8g.4xlarge in us-west-2
       On-demand:  $0.6381/hr (live)
       TTL cost:   $0.80 (1.2 hr)
    
    📁 FSx Lustre filesystem (created by this launch)
       Capacity:   1200 GiB PERSISTENT_2 @ 125 MB/s/TiB
       Storage:    ~$174.00/month (~$0.2384/hr) at ~$0.145/GiB-month — approximate
       Lifecycle:  ephemeral — reclaimed asynchronously after the instance is gone,
                   not by `spawn terminate`; it bills until then
       ⚠️  --cost-limit counts this, and refuses the launch if it exceeds the cap on its
           own — but it cannot RECLAIM it: the filesystem outlives the instance, so it
           keeps billing after the instance is gone.

    That is the $174/month you calculated by hand, now printed before anything is created. --cost-limit covers storage as well as compute and refuses a launch whose storage alone exceeds the cap, with --allow-cost-limit-overrun as the explicit opt-out. The one honest limitation is stated rather than papered over: the cap can refuse the filesystem but cannot reclaim it.

    Finding 2 (terminate said nothing) — fixed. cmd/fsx_lease.go reads both leases off the instance tags, describes the filesystem for size and state, and prints the id, the monthly cost, the lifecycle's actual reclamation semantics, and spawn fsx delete <id>. Deliberately read-only — terminate reports, it does not delete as a side effect.

    Finding 1 (the CREATING race) — was already handled. Your caveat was a good instinct but not the cause: fsxInUse counts spawn:fsx-pending as well as spawn:fsx-id, and the #210 ephemeral-orphan net makes an ephemeral filesystem eligible after a 30-minute grace regardless of max-age. A filesystem that finishes creating after its instance is gone is exactly what that net is for.

    What is actually left, and the decision that now resolves it

    Nothing in the code. The leak happened because no reaper scanned 942542972736 — and as recorded above, that account's organization forbids trusting an external principal, so it cannot be added to REAPER_ROLE_ARNS.

    That question has now been settled in the general case: the reaper should be in-account, CLI-converged and durable, with the infra account as a read-only observer. Three reasons, and the first is this issue:

    1. A central-only reaper is impossible for 942542972736. Any design that only works with cross-account trust leaves this account — and every account under a similar policy — permanently uncovered. That is not an edge case; it is the account where the 1.2 TiB leak happened.
    2. A central reaper holding terminate rights in customer accounts is the largest blast radius in the system. lambda/ttl-reaper: 'make deploy' defaults would DISARM the live production reaper and silently drop its DNS/alarm config #650 disarmed the live production reaper by accident; the mirror-image mistake terminates running work in every account at once.
    3. "Ephemeral" is the wrong axis for a backstop. Something that expires reintroduces the hole it exists to close.

    spawn reaper deploy already implements this and installs unarmed (dry-run) by design. The remaining step for this issue is operational — deploy it into that account, read a cycle of dry-run logs, then arm — and I am not doing a live deploy without asking first.

    Leaving this open on the operational step rather than closing it, since the symptom you reported is only genuinely gone once something is actually reclaiming filesystems in that account.

  4. scttfrdmn commented on Oct 5, 2026

    @scttfrdmn
    ContributorAuthor

    The operational gap is closed. An in-account reaper is deployed and armed in 942542972736 / us-west-2 — the exact account and region where your 1.2 TiB filesystem sat.

    Deployed

    Function:  spawn-ttl-reaper-selfscan
    Version:   0.121.0
    State:     ARMED — it reclaims expired spawn-managed resources
    Schedule:  rate(10 minutes) (enabled)
    Scanning:  us-west-2
    

    This is the in-account shape, so it resolves the blocker recorded above: the account's organization forbids trusting an external principal, and this trusts nothing but Lambda. Verified against the deployed artifact rather than the template:

    • Trust policy is lambda.amazonaws.com only — zero matches for any spore.host account id, ExternalId, or an "AWS" principal.
    • The inline policy contains no sts:AssumeRole at all.
    • The only attached managed policy is AWSLambdaBasicExecutionRole (logs).
    • accounts=[self] in the runtime log confirms it never assumes anything.

    IAM simulated in both directions, because an applied policy is not an authorized one:

    simulated result
    TerminateInstances on spawn:managed=true allowed
    TerminateInstances on spawn:managed=false implicitDeny
    TerminateInstances with no tag implicitDeny
    sts:AssumeRole into 966362334030 implicitDeny
    fsx:DescribeFileSystems / DeleteFileSystem allowed
    s3:DeleteBucket, iam:CreateRole, ec2:RunInstances implicitDeny

    Validated end to end, both directions

    Three dry-run cycles came back clean — but every one scanned an empty account (Scanned:0), so they proved the reaper runs and authorizes and nothing about whether it classifies correctly. It had never evaluated a single resource.

    So after arming I gave it one t4g.nano to look at, launched with aws ec2 run-instances rather than spawn launch deliberately — no spored. With spored installed, in-instance enforcement would have terminated it and the result could not be attributed. This way the reaper is the only actor.

    Sparing a live instance (the half that matters, and the one with real consequences — #650 disarmed the production reaper, and the mirror-image bug kills running jobs):

    15:21:34 ttl-reaper done: {Accounts:1 Scanned:1 Expired:0 Reaped:0 Errors:0}
             instance state: running
    

    Seen, evaluated, judged unexpired, left alone.

    Reaping an expired one, after moving the deadline five minutes into the past:

    15:31:34 REAPED i-0e4dc797a9ab7e56a (reaper-validation-713) in self/us-west-2
             — ttl-deadline (age 13m0s, deadline 2026-10-05T15:18:16Z)
    15:31:34 ttl-reaper done: {Accounts:1 Scanned:1 Expired:1 Reaped:1 Errors:0}
             instance state: terminated
    

    Independent leak-check afterwards: 0 non-terminated instances, 0 available volumes, 0 FSx filesystems in the region. Total cost of the validation was a fraction of a cent.

    Two caveats worth your attention

    REAPER_REGIONS=us-west-2 only. Your leak was there, so it is covered — but a launch into any other region in this account is still unbackstopped.

    max-age=168h, graceful=false. An instance with no spawn:ttl-deadline is reclaimed after 7 days regardless, and it terminates rather than stopping first.

    Still open on this issue

    Nothing in spawn's code, and nothing operational for us-west-2. What remains is the thread this issue fed into: nothing reaps the reaper's own leavings — the role, the schedule, and the spawn-reaper-artifacts-942542972736-us-west-2 bucket this deploy created, holding a 25 MB artifact. That belongs to "who reaps the reapers" rather than here, and this deployment just added one more instance of it.

  5. scttfrdmn commented on Oct 9, 2026

    @scttfrdmn
    ContributorAuthor

    Verified end to end today. Closing.

    All three code findings are shipped, and the operational gap — the one that
    actually caused this leak — is confirmed live rather than merely deployed.

    Code, re-checked against main today

    suggestion where
    reap an ephemeral FSx whenever its instance is gone, not just on the happy path lambda/ttl-reaper/main.go:890, ephemeralOrphanGrace = 30m (#210)
    say something on terminate fsxLeaseNoticeFor → renderFSxLeaseNotice, printing size, ~monthly cost, and lifecycle-specific wording (ephemeral / durable / untagged)
    FSx in the cost preview cmd/fsx_cost.go

    The in-account reaper is firing, not just present

    This is the part worth checking properly: a reaper that is deployed and armed but
    never invoked looks identical to a working one from its configuration alone.

    function:   spawn-ttl-reaper-selfscan   State: Active   (deployed 2026-10-05)
    armed:      REAPER_DRY_RUN=false        REAPER_SCAN_SELF=true
    region:     REAPER_REGIONS=us-west-2
    schedule:   spawn-ttl-reaper-selfscan-schedule   rate(10 minutes)   ENABLED
    last run:   2026-10-09T04:51:34Z        (≈7 minutes before this check)
    

    The filesystem, and the account

    fs-0d0d29cb9e4be40df  →  FileSystemNotFound
    FSx in 942542972736:     0 in us-west-2, 0 in us-east-1
    FSx in the spore.host accounts: 0 in us-east-1 and us-west-2 (both)
    

    Two caveats that remain true

    • REAPER_REGIONS=us-west-2 only. Your leak was there, so it is covered, but
      a launch into any other region in that account is still unbackstopped.
    • REAPER_MAX_AGE is unset, so the function's built-in default applies, and
      reclamation terminates rather than stopping first. An instance with no
      spawn:ttl-deadline is still reclaimed eventually, by that default rather than
      by an explicit setting.

    Where the remainder went

    This issue's last comment identified the genuine leftover as "nothing reaps the
    reaper's own leavings"
    — the role, the schedule, and the
    spawn-reaper-artifacts-942542972736-us-west-2 bucket this deploy created. That
    is #653, which is now moving: #770 bounds the one control-plane artifact measured
    to grow without limit (10 log groups with no retention, 51 MB), and the
    measurement there corrected two of #653's own priorities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions