Skip to content

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

Closed

Description

@scttfrdmn

Why (and why first)

Any feature that auto-creates an FSx Lustre filesystem (lagotto#43 durable storage; spawn launch --fsx-create; a future spawn fsx create) has an orphan window where a ~$150–200/mo PERSISTENT_2 1.2 TB filesystem can be left running with nothing watching it:

  • capacity never appears, so the FSx idles until something reclaims it;
  • the owning instance dies mid-provision, or terminates but the teardown call fails;
  • any bug/crash/partial failure between create and delete.

Given the project's existential cost-control stance and the lifecycle invariant (#72, "everything dies eventually"), no FSx auto-create of any shape should ship before the reaper can reclaim an orphaned FSx. This is the gate, not a follow-up — filing it as the foundation the lagotto#43 work (and spawn launch --fsx-create, which today has no reaper backstop either) depends on.

Current state (scoped against the code)

  • The ttl-reaper is EC2-only (lambda/ttl-reaper/main.go) — it has no FSx awareness.
  • FSx-create already tags spawn:managed=true, spawn:fsx-created=<RFC3339>, spawn:fsx-s3-bucket, spawn:fsx-stack-name, etc. (pkg/aws/fsx.go:109). But there's no spawn:ttl-deadline on FSx, so there's no per-filesystem deadline to key on yet.
  • The delete call lives inline in the fsx delete CLI command (cmd/fsx.go:331), not as a reusable pkg/aws method — the reaper can't import cmd/.

Proposed work

  1. Stamp a deadline at create. Add spawn:ttl-deadline (and/or rely on a max-age from spawn:fsx-created) when an FSx is auto-created, so the reaper has an explicit, launch-anchored deadline — mirroring how instances are evaluated (evaluate() in the reaper).
  2. Extract a reusable delete. Move the DeleteFileSystem logic from cmd/fsx.go into pkg/aws (e.g. DeleteFSxFilesystem) and call it from both the CLI and the reaper.
  3. Reaper scans FSx per account×region (fsx:DescribeFileSystems, filtered to spawn:managed=true), and reclaims those past their deadline / max-age — alongside the existing EC2 scan, honoring REAPER_DRY_RUN and REAPER_NOTIFY_URL the same way.
  4. ⚠️ Don't delete un-flushed data. An FSx with an active S3-export DRA must finish exporting before deletion, or the reaper recreates the exact --pre-stop does not reliably flush before TTL-triggered terminate → data loss on ephemeral storage #184 data-loss it's meant to prevent. The reaper must either confirm the DRA is idle/caught-up, or use FSx's export-on-delete / final-export semantics — not a blind DeleteFileSystem. This is a real design point.
  5. IAM: the reaper's role (and the cross-account REAPER_ROLE_ARNS roles) need fsx:DescribeFileSystems + fsx:DeleteFileSystem (+ DRA describe) — deploy-side.

Acceptance

  • A spawn:managed FSx past its deadline/max-age is reclaimed by the reaper (dry-run logs it; enforce mode deletes it), with the export-flush safety in ci: add coverage ratchet floor (22%) #4.
  • spawn launch --fsx-create filesystems are covered too (they're orphan-prone today with no backstop).
  • Notified via REAPER_NOTIFY_URL like instance reaps.

Blocks: lagotto#43 (durable FSx for auto-launch) and a spawn fsx create command. Relates to #72, #184.

Activity

  1. added
    enhancement
    area:lifecycle
    area:storage
    area:cost
    on Jun 16, 2026
  2. scttfrdmn commented on Jun 16, 2026

    @scttfrdmn
    ContributorAuthor

    Refcount/lease model — and the exact mechanism it rests on

    Traced how an FSx actually attaches to a spore today, because the reaper's safety depends on it:

    Association is one-directional, instance-only:

    1. Launch writes three tags on the instance: spawn:fsx-id, spawn:fsx-mount-name, spawn:fsx-mount-point (buildTags, pkg/aws/client.go:653).
    2. First-boot user-data (pkg/userdata/storage.go GenerateStorageUserData) runs the actual mount -t lustre <dns>@tcp:/<mountname> <mountpoint> + an /etc/fstab line.

    The FSx itself records nothing about who mounted it — a Lustre mount is just a client connection. So an FSx with no back-reference gets no reaper safety. That's the gap to close.

    Refcount via the forward tag (no new write path). The reaper should compute an FSx's refcount by joining on the tag the launch already writes:

    reap fs-Y iff spawn:managed=true AND no live instance has tag:spawn:fsx-id = fs-Y (state ∈ pending/running/stopped) AND (past spawn:ttl-deadline OR idle-since-last-user > grace).

    This is a pure read-side change in the reaper (DescribeInstances filtered by spawn:fsx-id), needs zero changes to the mount path or spored, and self-heals leaked leases (a vanished instance simply drops out of DescribeInstances, lowering the count). It also means even a hand-mounted --fsx-id filesystem gets refcount protection for free. The eventual-consistency edges are covered by the grace window — a race can only delay a reap (cost), never reap a live FS (data loss), so no distributed lock is warranted.

    Supersedes the explicit spawn:fsx-user-<id>-tags-on-the-FSx idea (more moving parts, leaks on unclean death, requires writing tags to a resource the instance doesn't own).

    Mechanism gap this also surfaces (for the Path-B work, not this issue)

    The lustre mount runs once at first boot via user-data. For instance-owned FSx created asynchronously (the lagotto "launch instance + FSx together" path), the FS isn't AVAILABLE at boot, so a baked-in mount fails. That path needs FSx mounting moved out of first-boot user-data into a spored "wait-for-pending-FSx → mount" capability — tracked with the Path-B launch work, not here. This reaper issue stands on its own regardless.

  3. added a commit that references this issue on Jun 25, 2026
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

    area:costarea:lifecyclearea:storageenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions