Skip to content

fix: ttl-reaper deletes DNS on reap (#247) + deploy-script build (#248) - #249

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/247-248-reaper-dns-and-deploy-build
Jun 25, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/247-248-reaper-dns-and-deploy-build

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Two fixes. The substantive one (#247) makes the ttl-reaper clean up DNS, eliminating the record leak behind the 61 orphans in spore.host. The other (#248) is a one-line deploy-script build fix.

#247 — reaper deletes DNS on reap (manual, out-of-band)

spored's graceful shutdown deletes its DNS record, but the reaper is a backstop that only fires when spored failed — so reaped instances were leaking their A records (and the #121 friendly-name alias CNAME) into the zone indefinitely.

Per the design principle (a dead daemon can't clean up after itself), the reaper does the teardown itself, out-of-band — it does not wake spored:

  • evaluate() captures spawn:dns-name / spawn:account-base36 / spawn:account-name.
  • after a successful terminate, it deletes the canonical A-record {dns-name}.{account-base36}.{domain} and, when the instance carried the Use the AWS account's friendly name (not just base36 account ID) in DNS and elsewhere #121 alias, the {dns-name}.{account-name}.{domain} CNAME.
  • uses the reaper's own infra-account Route53 creds (the zone lives there, not in the per-instance cross-account role).
  • best-effort + REAPER_DRY_RUN-aware, and runs after the terminate so it can never block the hard-deadline guarantee (Guardrail: TTL must always terminate — never add a TTL→stop mode #72).
  • enabled via REAPER_DNS_ZONE_ID + REAPER_DNS_DOMAIN (both empty = off → no route53 IAM attached). template.yaml gains the scoped route53:ChangeResourceRecordSets/ListResourceRecordSets behind a DnsTeardownEnabled condition.

This mirrors the reaper's existing ownership of FSx cleanup (#192/#212).

Note on the friendly-name alias

Confirmed the #121 capability is an alias, not a replacement: the base36 A-record stays authoritative and {record}.{account-name}.{domain} is an added CNAME. So the reaper deletes both when spawn:account-name is set.

#248 — deploy-custom-dns.sh build

go build main.go → go build . (the handler is split across main.go + signature.go, so the single-file build failed with undefined: verifyInstanceIdentitySignature).

Tests

TestDNSRecordsToDelete (pure record construction: A-only / A+alias / no-dns / missing-base36 / empty-domain) and TestEvaluate_PopulatesDNSFields. cfn-lint template.yaml clean; go test ./... green.

Follow-up (not in this PR)

Sweeping the ~61 existing orphans is a one-off cleanup — call it separately (this PR stops new ones).

#247 — the reaper now tears down a reaped instance's Route53 records itself.
spored's graceful shutdown deletes its DNS record, but the reaper only fires when
spored FAILED (dead/wedged/never-ran), so reaped instances leaked their A-records
(and the #121 friendly-name alias CNAME) into the zone forever — the root cause of
the orphaned records observed in spore.host. Per the backstop principle, the
reaper does NOT wake the dead daemon to clean up; it performs the teardown
out-of-band:
- captures spawn:dns-name / spawn:account-base36 / spawn:account-name in evaluate()
- deletes {dns-name}.{account-base36}.{domain} (canonical A) and, when present,
  {dns-name}.{account-name}.{domain} (the #121 alias CNAME)
- uses the reaper's OWN (infra-account) Route53 creds — the zone lives there, not
  in the per-instance cross-account role
- best-effort + REAPER_DRY_RUN-aware; runs AFTER terminate so it can never block
  the hard-deadline guarantee (#72)
- enabled via REAPER_DNS_ZONE_ID + REAPER_DNS_DOMAIN (both empty = off, no
  route53 IAM attached); template.yaml gains scoped
  route53:ChangeResourceRecordSets/ListResourceRecordSets + a DnsTeardownEnabled
  condition. Mirrors the reaper's existing FSx-cleanup ownership (#192/#212).

#248 — scripts/deploy-custom-dns.sh built the Lambda with `go build main.go`,
which misses signature.go (undefined: verifyInstanceIdentitySignature). Fixed to
`go build .`.

Tests: dnsRecordsToDelete (pure: A-only / A+alias / no-dns / missing-base36 /
empty-domain) + evaluate() populates the DNS fields. cfn-lint clean.
Fixes #247, #248.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 1c2b40a into main Jun 25, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/247-248-reaper-dns-and-deploy-build branch June 25, 2026 07:09
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