Skip to content

feat(ttl-reaper): reclaim orphaned FSx Lustre filesystems (refcount-aware) (#192) - #196

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/192-fsx-reaper
Jun 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/192-fsx-reaper

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #192 — the cost backstop that gates the FSx auto-create chain (#193 contract → #194 ephemeral path → lagotto#43). The reaper was EC2-only; an auto-created FSx (~$150–200/mo) had nothing watching it.

What it does

The reaper now scans spawn-managed FSx per account×region and reclaims a filesystem only when all hold:

  • past deadline — spawn:ttl-deadline, or (lacking one) older than the max-age ceiling, same logic as instances;
  • refcount 0 — no live instance references it. Computed by joining on the spawn:fsx-id tag already written at launch for every mount path; a single live user (pending/running/stopping/stopped) blocks the reap. Self-heals leaked leases (a vanished instance simply drops out of DescribeInstances);
  • AVAILABLE — never touches CREATING/DELETING.

Safety

  • Export-flush (--pre-stop does not reliably flush before TTL-triggered terminate → data loss on ephemeral storage #184): DeleteFileSystem omits SkipFinalExport, so an attached S3-export DRA flushes remaining data on delete instead of dropping it.
  • Fail-safe refcount: if the refcount check errors, the FS is held back (counted skipped), never blindly reaped.
  • Honors REAPER_DRY_RUN (logs "WOULD reap" + notifies, deletes nothing) and REAPER_NOTIFY_URL, mirroring instance reaps. New FSx* counters on Summary.
  • IAM (deploy-side): the reaper role + cross-account roles need fsx:DescribeFileSystems + fsx:DeleteFileSystem.

Refactor

Inline DeleteFileSystem in cmd/fsx.go → shared Client.DeleteFSxFilesystem (pkg/aws/fsx.go), so spawn fsx delete and the no-SkipFinalExport semantics live in one place.

Tests

evaluateFSx: past-deadline reaped, within-deadline spared, non-spawn-managed ignored, max-age fallback, CREATING skipped. reaper + pkg/aws + cmd green; go vet/gofmt clean.

Note: the reaper is a separate Go module and talks to AWS via the raw fsx SDK (it doesn't import pkg/aws), so the refcount/delete logic lives in the reaper; pkg/aws.DeleteFSxFilesystem serves the CLI. Same no-SkipFinalExport behavior in both.

Unblocks #193 / #194 / lagotto#43.

…ware) (#192)

The cost backstop that gates any FSx auto-create feature (lagotto#43, #193/#194).
An auto-created FSx (~$150-200/mo) currently has nothing watching it; the reaper
was EC2-only.

Reaper now scans spawn-managed FSx per account×region and reclaims one only when:
- it's past spawn:ttl-deadline (or, lacking one, older than max-age), AND
- NO live instance still references it — refcount computed by joining on the
  spawn:fsx-id tag already written at launch (a single live user blocks the
  reap; self-heals leaked leases since a gone instance drops from
  DescribeInstances), AND
- it's AVAILABLE (never touch CREATING/DELETING).

Deletion omits SkipFinalExport so an attached S3-export DRA flushes remaining
data on delete, not dropping it (#184). Honors REAPER_DRY_RUN / REAPER_NOTIFY_URL
like instance reaps; FSx counts added to Summary.

Also extracts the inline cmd/fsx.go delete into a shared
Client.DeleteFSxFilesystem (pkg/aws), used by both `spawn fsx delete` and (for
the CLI) the same no-SkipFinalExport semantics.

Tests: evaluateFSx (past-deadline / within-deadline / not-managed / max-age
fallback / not-available). reaper + pkg/aws + cmd green; vet/fmt clean.

Closes #192
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/fsx.go 0.00% 14 Missing ⚠️
cmd/fsx.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 3e9367a into main Jun 16, 2026
6 of 7 checks passed
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.

ttl-reaper must reclaim orphaned FSx Lustre filesystems (cost backstop; prerequisite for any FSx auto-create)

1 participant