Skip to content

fix(fsx): stop promising synchronous ephemeral reaping; surface FSx in terminate and estimates (#613) - #617

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/613-fsx-ephemeral-honesty
Sep 26, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/613-fsx-ephemeral-honesty

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Addresses asks 2 and 3 of #613 only — the CLI-side honesty and visibility work.

Ask 1 is not in this PR, and the issue stays open until it lands. The reap
logic itself is correct: the ttl-reaper's ephemeral-orphan safety net covers
exactly the reported scenario (a filesystem whose instance vanished while it was
still CREATING). The actual leak cause is operational — the deployed reaper's
account list doesn't include the account the launch ran in — and is being fixed
separately. Nothing here touches lambda/ttl-reaper/, and no new reaping
mechanism is added.

A. The wording was the bug

--fsx-lifecycle ephemeral said "reaped when this instance terminates".
cmd/terminate.go has no FSx handling at all. Reclamation is asynchronous: the
out-of-band reaper deletes the filesystem on a later pass, once it is AVAILABLE
and no live instance carries either lease tag (spawn:fsx-id or
spawn:fsx-pending), after a grace period, and only in accounts it scans. So the
promise is grace-delayed, best-effort and contingent on infrastructure — none of
which the old text admitted.

Reworded consistently in --fsx-lifecycle's help, both --fsx-create /
--fsx-ttl validation errors, and docs/durable-storage-fsx.md (the lifetime
table, the ephemeral bullet, the end-of-job export note, and the reaper's
"promise" section, which now states plainly that reclamation is asynchronous
rather than transactional and depends on the reaper covering your account).
docs-gen/launch.md regenerated via make gen-docs.

A drift gate (cmd/fsx_promise_gate_test.go) fails if the shorter, friendlier,
false sentence regrows anywhere in cmd/, docs/, docs-gen/ or the README,
and also asserts the positive half — the help must actively say reclamation is
asynchronous, since silence reads as "it just works".

B. spawn terminate surfaces the filesystem

Read from the instance's own lease tags, then enriched with a read-only
DescribeFileSystems:

📁 FSx Lustre filesystem fs-0d0d29cb9e4be40df (1200 GiB, AVAILABLE)
   Billing while it exists: ~$174.00/month at the default throughput tier (approximate).
   It is NOT deleted by this command.
   Lifecycle 'ephemeral' means it is reclaimed asynchronously once no instance
   references it — by the out-of-band reaper, minutes-to-hours later, and only
   in accounts the reaper scans. Until then it keeps billing.
   Confirm:  spawn fsx list
   Delete:   spawn fsx delete fs-0d0d29cb9e4be40df
  • Print, don't act. Terminate still deletes nothing but the instance; its
    blast radius is unchanged.
  • The spawn:fsx-pending (still-provisioning) lease is reported too, tagged
    "still provisioning" — that's the window this issue hit.
  • A filesystem with no spawn:fsx-lifecycle tag (i.e. one you brought with
    --fsx-id) is described as one spawn will never reclaim, rather than
    inheriting the ephemeral wording. Avoiding a second false promise.
  • Job-array terminate prints one notice per distinct filesystem (an array
    created with --fsx-create shares one).
  • Lookup failure (no fsx:DescribeFileSystems, filesystem already gone) still
    prints the id and the "not deleted by this command" line — being unable to
    describe it is not a reason to go quiet.

spawn stop/hibernate got the same treatment, with the fact that matters
there: stopping ends the compute bill but the filesystem keeps running and
billing, and the stopped instance still holds the lease that blocks any
automatic reclamation. A "stopped to save money" instance silently accruing
~$174/month is the same surprise in a different shape.

C. FSx in the cost preview

--estimate-only used to print TTL cost: $0.80 for a launch about to create a
~$174/month filesystem. Now:

📁 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, us-east-1 list price
   Lifecycle:  ephemeral — reclaimed asynchronously after the instance is gone,
               not by \`spawn terminate\`; it bills until then
   ⚠️  --cost-limit does NOT cover this: it caps compute spend only, so the
       filesystem keeps billing after the instance stops. Check with \`spawn fsx list\`;
       delete with \`spawn fsx delete <fs-id>\`.

The --cost-limit limitation is stated at the point of use, not only in flag
help. The plan builder mirrors the create path's own defaults (throughput 0→125,
capacity 0→1200) so the preview can't quote a shape the launch wouldn't use.

There was no existing storage-pricing helper, so the rate table lives in exactly
one named place — fsxLustreUSDPerGiBMonthByThroughput in cmd/fsx_cost.go —
with a comment saying it's an approximation, where it came from (AWS FSx for
Lustre pricing page, PERSISTENT_2 SSD, us-east-1, Sept 2026), and that
PERSISTENT_2 folds the throughput tier into the per-GiB price. No attempt is
made to have --cost-limit actually enforce against FSx
— that's a behavioural
change beyond this issue.

Tests (unit only, zero real AWS)

  • cmd/fsx_cost_test.go — the estimate contains capacity, throughput, the
    monthly figure and the not-covered-by---cost-limit caveat with --fsx-create
    set, and produces nothing without it; durable names its TTL; the rate table is
    pinned (including the unknown-tier fallback and 0-capacity → price nothing).
  • cmd/fsx_lease_test.go — the notice renders from tags with fsx-id, with
    fsx-pending, and is absent with neither; untagged filesystems aren't claimed
    as reaped; stop says it keeps billing and doesn't borrow terminate's wording.
  • cmd/fsx_promise_gate_test.go — the misleading phrasing is gone and stays gone.

Both renderers are pure (io.Writer/string in, no client), and the AWS lookup is
behind a package-level seam (enrichFSxLease), the same pattern as
resolveLaunchDryRunPrice.

Gates

gofmt -w clean · go vet ./... clean · go build ./... clean ·
go test ./... all green · make gen-docs run and docs-gen/ committed
(check-docs passes) · staticcheck ./... — 61 findings before, the same 61
after, diff empty
(no new findings; spawn has no golangci-lint).

CHANGELOG updated under ## [Unreleased]. No version promoted, no tag.
Suggested bump: PATCH — the fix is corrected text plus additive output on
paths that already print a summary; no flag, schema or behaviour change. (MINOR
would be defensible if you consider the new terminate/stop block a feature.)

Refs #613

…n terminate and estimates

--fsx-lifecycle ephemeral said the filesystem is "reaped when this instance
terminates". Nothing reaps an FSx at terminate time: cmd/terminate.go has no
FSx handling at all. Reclamation is asynchronous — the out-of-band ttl-reaper
deletes the filesystem on a later pass, once it is AVAILABLE and no live
instance carries either lease tag (spawn:fsx-id or spawn:fsx-pending), after a
grace period, and only in accounts the reaper is configured to scan. A user who
read that help, ran `spawn terminate`, and saw it succeed reasonably concluded
their 1.2 TiB (~$174/month) filesystem was gone. It wasn't.

Three changes, all read-only:

- Reword the flag help, the --fsx-create/--fsx-ttl validation errors, and
  docs/durable-storage-fsx.md to say when reclamation actually happens. A gate
  test fails if the shorter, false sentence regrows.
- `spawn terminate` now names the filesystem (id, size, state), says it is NOT
  deleted by the command, and gives `spawn fsx list` / `spawn fsx delete <id>`.
  It handles the still-provisioning spawn:fsx-pending lease too, and does not
  claim ownership of a --fsx-id filesystem spawn didn't create. `spawn stop`
  prints the same filesystem with the point that matters there: compute stops
  billing, the filesystem does not. Terminate still deletes nothing but the
  instance.
- `--estimate-only` now prices the filesystem --fsx-create would create
  (capacity, throughput tier, approximate monthly cost) and states at the point
  of use that --cost-limit does not cover it.

The rate table lives in one named place (cmd/fsx_cost.go) with its source and
the fact that it is an approximation. pkg/aws gains DescribeFSxBrief, a nil-safe
read-only lookup: GetFSxFilesystem dereferences DNSName/MountName, which a
CREATING filesystem does not have — the exact state this issue hit.

Refs #613
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.33333% with 61 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/fsx_lease.go 63.01% 27 Missing ⚠️
pkg/aws/fsx.go 0.00% 24 Missing ⚠️
cmd/terminate.go 0.00% 4 Missing ⚠️
cmd/fsx_cost.go 95.23% 1 Missing and 1 partial ⚠️
cmd/launch_single.go 0.00% 2 Missing ⚠️
cmd/state.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit e2a6e04 into main Sep 26, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/613-fsx-ephemeral-honesty branch September 26, 2026 04:50
scttfrdmn added a commit that referenced this pull request Sep 26, 2026
Promote the Unreleased section to [0.111.4] and update compare links.

PATCH: corrected false --fsx-lifecycle ephemeral wording plus additive FSx
notices in terminate/stop/hibernate and --estimate-only (#613, PR #617). No
flag, schema or behaviour change.
scttfrdmn added a commit that referenced this pull request Oct 1, 2026
…NT_2 storage rate (#627)

#618: GetFSxFilesystem dereferenced DNSName, LustreConfiguration.MountName and
StorageCapacity unconditionally. All three are optional in the API and a
filesystem still CREATING has no DNSName and no LustreConfiguration at all, so
reaching this during provisioning panicked instead of returning something
usable — and CREATING is the exact window spawn#613 was reported from. The tag
scan had the same shape (Tag.Key/Value are both optional).

The mapping is extracted as a pure fsxInfoFrom so it can be tested against any
lifecycle state without AWS; the new test panics against the pre-fix code. Empty
DNSName/MountName is the meaningful answer — a mount cannot be built without
them, so 'not ready' is reported rather than crashing.

#619: fsx info multiplied capacity by a hardcoded 0.22, commented '$0.22/GB-month
for SSD'. That is a PERSISTENT_1 rate applied to filesystems spawn creates as
PERSISTENT_2, whose rate at the default 125 MB/s/TiB tier is $0.145 — overstating
a 1200 GiB filesystem by ~52% ($264 vs $174). Since #617 made --estimate-only
quote storage cost, two spawn commands disagreed about the same filesystem.

It now reads the actual throughput tier off the filesystem and uses the single
shared rate table in cmd/fsx_cost.go (fsxLustreMonthlyUSD), with both derefs
guarded for the same CREATING case. A drift gate fails if any file in cmd/ names
an FSx rate in code again, and pins the rate to the PERSISTENT_2 values so
'one source' cannot be satisfied by centralising the wrong number.

Refs #618, #619
scttfrdmn added a commit that referenced this pull request Oct 3, 2026
--cost-limit was compute-only. That is how #613's launch committed a 1.2 TiB
filesystem at ~$174/month under a --cost-limit of 2.50 — roughly 70x the cap — while
the cap was respected to the letter the whole time, because it counted nothing but
compute-seconds.

The cap is now a TOTAL, enforced in the two places it can be. The split is not
cosmetic: --cost-limit is enforced INSIDE the instance by spored, and spored dies with
the instance, so it can never act on a resource that outlives it.

Up front (CLI, reliable): a launch whose storage commitment alone exceeds the cap is
REFUSED, naming the real monthly figure, what is being created, and why the cap cannot
bound it. --allow-cost-limit-overrun is the explicit escape hatch. Priced monthly, not
TTL-prorated, deliberately: once created, a filesystem bills until something deletes
it, and for a durable one nothing does automatically. A month is the floor.

In flight (spored): EBS now counts toward the cap alongside compute, because
terminating actually stops it — spawn's volumes carry DeleteOnTermination. Priced on
WALL CLOCK, not compute time: EBS bills while an instance is merely stopped, and
pricing it over compute hours would undercount exactly the case that matters. I wrote
it the wrong way first; the test that caught it asserts the 2h-wall-clock vs
1h-compute distinction explicitly.

FSx is deliberately NOT in the in-flight tally. Terminating does not delete a
filesystem, so firing the cap on FSx accrual would terminate the instance while the
thing it reacted to kept billing — an action that looks like enforcement and achieves
nothing. That commitment is refused at launch instead, and reclaiming what outlives an
instance stays the reaper's job (#624/#625).

Verified against the exact #613 invocation: now refused with the $174.00/month figure,
exit 1. Four cases confirmed NOT refused: the override flag, a compute-only launch
under a $0.01 cap (no regression), a cap that covers the storage, and a $180 cap
against the $174 minimum — so the error's advice is actionable.

Two test assertions updated rather than deleted, both of which encoded the OLD truth:
the #617 estimate test required 'does NOT cover' and the #615 billable view required
'caps COMPUTE only'. Both became false by design; they now assert what did NOT change
— that the cap cannot RECLAIM storage outliving the instance — and the first also
fails if the obsolete wording returns.

'compute only' survives where it is still accurate (cost.go, status.go), because those
lines describe compute FIGURES, not the cap's scope.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant