Skip to content

Wire DNSExpiryEligible into the reaper: the prober can now prove what the unmanaged-subdomain report refused to guess #466

Closed

Description

@scttfrdmn

The last open piece of #457. portal-account-prober (spore-host/spore-host#492, merged) now writes lifecycle verdicts to spore-portal-accounts, and accountlifecycle.DNSExpiryEligible is the gate. Nothing in the reaper reads it, so the verdict currently changes nothing.

Why this is the interesting half

The reaper's unmanaged-subdomain report (#458, main.go:1140) deletes nothing, and its comment explains exactly why:

An unmanaged subdomain is ambiguous: it could be an account that uninstalled and left records behind, or an account still in active use that someone forgot to add to REAPER_ROLE_ARNS. [...] we cannot tell the two apart precisely because we lack the credentials — DescribeInstances is how emptiness is proven, and it is unavailable here.

The prober has those credentials. It assumes each account's spore-portal-onboard role — a different role from the reaper's spawn-ttl-reaper-ec2, and one the registry actually knows about — and proves emptiness across 11 regions. So the ambiguity that justified the refusal is now resolvable for any account in the registry.

Both components already run in the infra account (966362334030), so the reaper can read the registry table directly. No cross-account anything.

The constraint that shapes this

DNS registration is boot-time only (pkg/agent/agent.go:234). There is no periodic re-registration. So a wrongly-deleted A-record does not self-heal — the spore keeps running and is simply unreachable by name until it reboots. Deletion is effectively irreversible from the user's side, which is why the rollout below is conservative even though the prober's verdict is well-guarded.

Decision taken

#457's policy table says unmanaged subdomains are "report, never delete" while its dormant row permits DNS expiry. Post-prober those point in different directions for the same record. Resolution: enrich the report unconditionally, gate deletion behind a new default-off flag.

  • Read the registry (dynamodb:Scan on spore-portal-accounts, kms:Decrypt on its CMK) — import github.com/spore-host/spore-host/lambda/accountlifecycle and reuse DNSExpiryEligible, do not re-implement it
  • Enrich the unmanaged-subdomain log line with the registry verdict, always on:
    UNMANAGED subdomain 4zlw3a1t.spore.host (account 390967728545)
      — 3 record(s), no credentials to reconcile
      → registry: DORMANT since 2026-06-28 (empty 30d, last probed 41m ago)
      → ELIGIBLE for expiry; set REAPER_DNS_EXPIRE=true to act
    
    This alone is a real improvement: today the operator gets "no credentials to reconcile" and has to go dig. Note the two uneligible cases are the informative ones — unreachable (we can no longer verify anything) and absent from the registry entirely (never onboarded through the portal, so the prober has no opinion and the old ambiguity stands in full).
  • New REAPER_DNS_EXPIRE (default false), on top of the existing REAPER_DNS_SWEEP + REAPER_DRY_RUN. Deliberately not folded into REAPER_DNS_SWEEP: that flag is already enabled in production, and reusing it would make an existing opt-in silently destructive on upgrade for a class of records it has never touched.
  • Refuse to delete when the registry Scan fails or returns zero rows — a truncated read makes every subdomain look unmanaged-and-unverifiable, which is the same "no deletion without a complete picture" rule the sweep already applies to partial live sets
  • Summary counters for eligible / ineligible / expired
  • IAM in the reaper's CFN template (template.yaml) for the Scan + kms:Decrypt
  • Tests: keep the eligibility decision pure and table-driven like orphanedRecords/sweepableRecord. Must cover — eligible-and-flag-off deletes nothing; registry-Scan-error deletes nothing; account absent from registry deletes nothing; unreachable deletes nothing; dormant + flag + not-dry-run deletes exactly that subdomain's A-records and no CNAMEs

Not in scope

Offboard has no caller anywhere yet, so the offboarded status is currently unreachable in production. Wiring the human-initiated path (CLI or portal) is separate; DNSExpiryEligible already returns true for it, so this work needs no change when it lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions