Skip to content

doctor: detect real reaper coverage instead of always warning; warn at launch when it matters - #631

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/624-reaper-coverage-warning
Oct 2, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/624-reaper-coverage-warning

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Refs #624.

The check was a constant

spawn doctor's "TTL reaper backstop" was a hardcoded return "", fmt.Errorf("not detected from this account …") — the same warning in every account, covered or not, on the reasoning that a launch account can't see a reaper living elsewhere.

So it carried no information. And a warning that always fires is one people learn to scroll past: an account where nothing reclaims expired instances read exactly like a healthy one. That is how a spawn:managed instance sat stopped for 13 days past its TTL, still billing EBS, while doctor said what it says everywhere.

Coverage does leave local evidence

Two shapes, and nothing else creates either:

  1. a reaper Lambda running in this account (REAPER_SCAN_SELF) — spawn-ttl-reaper-*
  2. the conventional spawn-ttl-reaper-ec2 role, which exists only because an operator granted a reaper elsewhere access

Verified against three real accounts before writing the code:

account Lambda role verdict
infra spawn-ttl-reaper-production — covered (in-account)
spore-launching — present covered (cross-account)
the one with the 13-day orphan — — not covered

And the shipped check, run against each:

$ spawn doctor      # infra
✓ TTL reaper backstop: in-account reaper spawn-ttl-reaper-production

$ spawn doctor      # spore-launching
✓ TTL reaper backstop: cross-account role spawn-ttl-reaper-ec2

$ spawn doctor      # the uncovered one
⚠ TTL reaper backstop
    → no reaper runs in this account and no spawn-ttl-reaper-ec2 role grants one access —
      TTL is enforced only from inside the instance by spored, which cannot act on a
      STOPPED instance and does nothing if it dies

"Could not determine" is now distinct from "there is none." If a probe can't complete (no lambda:ListFunctions, no iam:GetRole), the check says so rather than asserting an absence it can't prove — and doctor no longer prepends "no out-of-band reaper configured" to that verdict. A Pass names its evidence, so an operator can tell the two coverage shapes apart.

Launch-side warning, only where it changes the outcome

Before anything is spent, and including under --dry-run / --estimate-only — those are the "what would this cost me" surfaces, and a reaper that won't reclaim an ephemeral filesystem is exactly such a cost.

Two cases qualify:

A plain --on-complete terminate does not warn. spored handles it from inside and the reaper is only its backstop; warning there would recreate exactly the noise this change removes. Verified on real accounts:

flags account result
--on-complete stop uncovered ⚠ names EBS
--fsx-lifecycle ephemeral uncovered ⚠ names 1200 GiB / ~$174/month
--on-complete terminate uncovered silent
--on-complete stop covered silent

Tests

pkg/aws/reapercoverage_test.go — the three states stay distinguishable (the core of #624); advice fires for stop/hibernate/ephemeral-FSx and is silent for terminate, no flags, durable FSx, and any covered account; the warning names the cost (EBS, 1200 GiB, $174) rather than describing the architecture; both flags together report both consequences; and an undetermined verdict hedges ("Could not confirm") instead of asserting absence.

pkg/doctor/doctor_test.go — doctor must not prepend an unproven claim, and a Pass must carry its evidence. Verified to fail against the old hardcoded wording.

Gates

gofmt · go vet ./... · go build ./... · go test ./... all green · make check-docs clean · go mod tidy clean · staticcheck zero added (diffed by message).

Note

This closes the visibility half of the reaper gap. #625 — a supported way to run a reaper in your own account, which governed orgs need because the cross-account grant is forbidden there — is still open and is the half that makes an uncovered account fixable rather than merely knowable.

Suggested bump: MINOR (doctor's verdict changes meaningfully, and there's a new launch-time warning).

…arn at launch when it matters

spawn doctor's 'TTL reaper backstop' check was a hardcoded 'not detected' —
ReaperConfigured returned the same error unconditionally, on the reasoning that a
launch account cannot see a reaper living elsewhere. The effect was a check that
printed an identical warning in EVERY account, including accounts the reaper does
cover. It carried no information, and a warning that always fires is one users learn
to scroll past: an account where nothing reclaims expired instances read exactly like
a healthy one. That is how a spawn:managed instance sat stopped for 13 days past its
TTL, still billing EBS, while doctor said what it says everywhere.

Coverage does leave local evidence, in two shapes: a reaper Lambda running in this
account (REAPER_SCAN_SELF), or the conventional spawn-ttl-reaper-ec2 role, which
nothing but that setup creates. Verified against three real accounts before writing
the code — the infra account matches the first, a spore-launching account the second,
and the account with the 13-day orphan matches neither.

'Could not determine' is now distinct from 'there is none', and doctor no longer
prepends 'no out-of-band reaper configured' to a verdict that only said it could not
tell. A Pass names its evidence so an operator can tell the two coverage shapes apart.

Launch-side: a launch that DEPENDS on the reaper warns when no reaper covers the
account, before anything is spent and including under --dry-run/--estimate-only. Only
two cases qualify — --on-complete stop/hibernate, where EBS keeps billing and spored
cannot act once the instance is stopped, and --fsx-lifecycle ephemeral, where only the
reaper ever deletes the filesystem. A plain --on-complete terminate does not warn:
spored handles it from inside and the reaper is only a backstop, so warning there
would recreate exactly the noise this removes.

Refs #624
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 29.54545% with 62 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/reapercoverage.go 41.66% 35 Missing ⚠️
cmd/launch_reaper_coverage.go 0.00% 16 Missing ⚠️
pkg/doctor/aws_prober.go 0.00% 10 Missing ⚠️
cmd/launch_single.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit e9d8840 into main Oct 2, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/624-reaper-coverage-warning branch October 2, 2026 22:07
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