Repository navigation
Description
The last unshipped reaper-side piece of #457. Three of its four policy branches now ship — dormant and unmanaged subdomain in #468/#466, the registry state machine in spore-host/spore-host#490 — but failure mode A is untouched:
The account goes away; its ARN stays in
REAPER_ROLE_ARNS. The reaper burns a failing assume-role every 10 minutes forever, and each failure incrementssum.Errors— the field that is supposed to mean investigate this. Permanent expected failures train the operator to ignore the error count.
Current behaviour
handler scans every account × region and counts every scan failure identically (lambda/ttl-reaper/main.go:475-479):
cands, scanned, err := r.scanRegion(ctx, acct, region, start)
sum.Scanned += scanned
if err != nil {
log.Printf("account %s region %s: scan error: %v", acct.label, region, err)
sum.Errors++
continue
}The credentials are lazy — stscreds.NewAssumeRoleProvider (main.go:275) doesn't call STS at init(), so a deleted role surfaces as a per-region scanRegion error rather than one startup failure.
The arithmetic: 11 default regions × 6 runs/hour = 66 sum.Errors per hour, per dead account, indefinitely. One uninstalled customer permanently pins the field at a number that can never return to zero without a human editing a deploy parameter.
Why this is the security-relevant half
Errors is the only channel that says a scan didn't happen. Everything else in Summary counts things that did. So a permanently-nonzero Errors doesn't just add noise — it destroys the one signal that distinguishes "nothing needed reaping" from "the reaper couldn't look." An instance running past its deadline in a region whose scan is failing looks exactly like a clean run.
Note the asymmetry with the deletion work in #466: there, being wrong deletes a live spore's DNS, so it got two opt-in switches. Here, being wrong means an over-deadline instance goes unreaped and unnoticed — which is precisely what #65 established the reaper to prevent.
What #457 proposed
Unreachable — assume-role fails for K consecutive runs while other accounts succeed: mark the registry row
unreachable, stop counting it intoErrors. No deletion.
accountlifecycle already implements the state machine and both of #457's traps, with K=6 configurable. So the classification exists; the reaper simply doesn't consult it for this purpose. #466 wired the registry read in for the DNS verdict — registryAPI.ListAccounts and the dynamodb:Scan grant are already in place, so the plumbing cost here is near zero.
The wrinkle that makes this non-trivial
The reaper's accounts and the registry's accounts are different sets, keyed by different roles. Per the #457 comment: REAPER_ROLE_ARNS holds spawn-ttl-reaper-ec2 (trusts the reaper) while the registry holds spore-portal-onboard (trusts phone-home). An account can be in one and not the other. So status == unreachable in the registry is evidence about a different role than the one the reaper just failed to assume, and a manually-deployed reaper role can be perfectly healthy in an account the portal has never seen — and vice versa.
Two consequences:
- The registry verdict alone cannot authorize quiescing a reaper role. It is corroboration, not proof.
- The reaper needs its own consecutive-failure counter for its role — but the reaper is a stateless Lambda, so "K consecutive runs" has nowhere to live. That's the real design question here, and it's why this is separable rather than a rider on Wire DNSExpiryEligible into the reaper: the prober can now prove what the unmanaged-subdomain report refused to guess #466.
Sketch, not a decision
- Distinguish the error classes.
AccessDenied/NoSuchEntityon the assume-role is a configuration fact; a throttle or an API outage is an operational one. They should not share a counter. A separateAccountsUnreachablefield, plus keepingErrorsfor genuine operational failures, restores the "investigate this" meaning without needing any persistence. - Count per account, not per region. One dead account should contribute 1 to a "couldn't reach" tally, not 11. This alone removes 98% of the noise and needs no state at all.
- Corroborate with the registry where a row exists — an account the prober independently marked
unreachableis strong evidence, and worth logging even though it can't be the sole authority. - Never silently drop an account from the scan set. Design: forget stale accounts — deprovisioning lifecycle for onboarded BYOA accounts #457's trap 1 (a recreated CFN stack changes the reaper role's physical ID and breaks every customer's trust policy at once) applies with full force. Quiescing means not counting it as a surprise, not stopping the attempt.
Both traps from #457 apply. Do the cheap, stateless part (error classification + per-account counting) before anything requiring persistence — it recovers most of the signal with none of the risk.
Activity
scttfrdmn commentedon Jul 31, 2026
PR #471 addresses this, but not as filed — worth recording why, since the original framing would have produced a worse reaper.
This was filed as "a dead account's assume-role failures poison
sum.Errorsforever" (11 regions × 6 runs/hour = 66/hour). The arithmetic was right; the conclusion was not.sum.Errorsdrives nothing:handlerendedreturn sum, nil— always nil, so the LambdaErrorsmetric never moved however many scans failed.Summarywent to one log line and back to EventBridge. Nothing read it.notify/notifyFSxfire only on successful reaps.AWS::CloudWatch::Alarmin all of spawn, and nothing in spore-host's OpenTofu either.So quietening the counter would have made the reaper calmer without making it safer.
Errorsis the only field inSummarythat says a scan did not happen — every other field counts something that did — so a reaper that silently reaches nothing was indistinguishable from a fleet with nothing expired. That is the blindness #65 created the reaper to prevent, one layer up.#471 therefore fixes the observability first (classification, per-account aggregation, three alarmable sentinels, four alarms) and the counter noise falls out as a consequence.
Deferred deliberately, and why:
handlerreturn non-nil. Tempting for the free LambdaErrorsmetric, but it would mark runs failed that did real work and change EventBridge retry behaviour. The explicit alarms are the honest mechanism.REAPER_ROLE_ARNSholdsspawn-ttl-reaper-ec2(trusts the reaper, deployed by hand) while the registry holdsspore-portal-onboard(trusts phone-home, created by onboarding). Either can be healthy while the other is broken, in both directions — so the registry can corroborate a denial in the log but can never be the authority for one.fix(ttl-reaper): add alarm for the reaper not being invoked at all (#475
fix(ttl-reaper): add alarm for the reaper not being invoked at all (#475