Repository navigation
fix(ttl-reaper): make the #438 DNS sweep reachable from make deploy - #453
Merged
Merged
Conversation
The sweep landed working but unreachable. `make deploy` never passed DnsSweep (nor DnsZoneId/DnsDomain) in --parameter-overrides, and `sam deploy` marks every parameter it isn't given as UsePreviousValue: on an existing stack that silently keeps whatever is already deployed, and on a fresh stack it falls back to the template default, 'false'. So the documented REAPER_DNS_SWEEP knob could not be turned on through the repo's own deploy path — the live production reaper still runs a pre-#438 build with no REAPER_DNS_SWEEP in its environment at all, while the spore.host zone holds an orphaned A-record of exactly the kind #438 exists to reap. Pass all three DNS parameters explicitly (DNS_ZONE_ID / DNS_DOMAIN / DNS_SWEEP) and document the enabling invocation, including that ROLE_ARNS must list every account with records under the zone — the sweep is per-account, so an account absent from that list is never reconciled. The verify section now says to confirm dns-sweep=true on the init line instead of assuming the feature is live, and shows what a sweep hit and a safety abort each look like in the log. Also extract the sweep's in-scope decision as a pure sweepableRecord() (no behavior change). It was inline with the paginated Route53 call and so untestable, despite being the highest-consequence logic in the sweep — a record wrongly judged in-scope is a live-DNS outage. Now covered for each exclusion: the subdomain apex, the zone apex, another account's subdomain, a deceptively similar suffix, the #121 friendly CNAMEs, and alias A-records that carry an AWS target rather than an IP. Verified read-only against the live spore.host zone: driving sweepAccountDNS in dry-run reconciled the real records and flagged win11-test.4zlw3a1t.spore.host -> 13.223.189.34 as an orphan (zero live instances), while sparing every alias and out-of-account record. The partial-scan safety path was also confirmed live — a cross-account DescribeInstances denial logged "aborting sweep for this account" and deleted nothing.
scttfrdmn
added a commit
that referenced
this pull request
Jul 31, 2026
* feat(taskcohort): cohort provider seam for a fungible worker pool (#70 P1) * feat(taskpool): SQS run-scoped queue + fungible worker pull-loop (#70 P1) * test(taskpool): queue lifecycle against real Substrate SQS (#70 P1) * fix(ttl-reaper): pass sam deploy parameters via a params file Found while performing the deploy #453 made possible: `make deploy` did not work at all with the parameters #453 added. sam matches the ENTIRE --parameter-overrides string against one regex, and an empty value breaks that match. NOTIFY_URL, DNS_ZONE_ID and DNS_DOMAIN are all empty by default, so the invocation either failed at argument parsing — Error: Invalid value for '--parameter-overrides': NotifyUrl= is not a valid format. — or, with the long ParameterKey=…,ParameterValue=… form, fell through to a different pattern and mis-keyed everything: Parameter overrides : {"Environment": "production", "DryRun": "true", "ParameterKey": "NotifyUrl,ParameterValue=", ...} That second form is the dangerous one. The deploy SUCCEEDS, but NotifyUrl was never overridden and a bogus "ParameterKey" parameter was submitted instead — a deploy that applies something other than what was asked for, with no error to notice. Repeating the flag per pair doesn't work either: the last occurrence wins and the rest are silently dropped. Generate a file:// params file instead, the only form that accepts empty values (verified: all eight parameters arrive intact, NotifyUrl as ""), and echo the mode-setting parameters — dry-run, scan-self, dns-sweep, zone, domain — so a deploy can never quietly leave a feature off. Not NotifyUrl: it's a Slack webhook secret and does not belong in a console or CI log. The generated file is gitignored and removed by `make clean`. Verified by deploying the reaper for real: parameters landed correctly, and the live init line now reads dns-sweep=true (sweep enabled, still dry-run) where before it had no dns-sweep field at all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #439 (the #438 DNS reconciliation sweep), from verifying that fix live.
The gap
The sweep is correct, but it could not be turned on through the repo's own deploy path.
make deploynever passedDnsSweep— norDnsZoneId/DnsDomain— in--parameter-overrides, andsam deploymarks every parameter it isn't given asUsePreviousValue(deploy_context.py:356).On an existing stack that silently keeps whatever is deployed; on a fresh stack it falls
back to the template default,
false. So theREAPER_DNS_SWEEPknob documented in theREADME had no supported way to be set.
This is not hypothetical. Production today:
spawn-ttl-reaper-productionlast updated 2026-06-25 — before feat(ttl-reaper): DNS reconciliation sweep for orphaned records (#438) #439 landed (07-23).REAPER_DNS_SWEEPkey at all, and the live init log linehas no
dns-sweep=field, confirming a pre-DNS records leak when spored doesn't exit through Cleanup (abrupt terminate/spot/crash) — no backstop reaper #438 binary.spore.hostzone holdswin11-test.4zlw3a1t.spore.host -> 13.223.189.34withzero live instances in any scanned region — precisely the orphan DNS records leak when spored doesn't exit through Cleanup (abrupt terminate/spot/crash) — no backstop reaper #438 exists to reap.
390967728545) isn't inRoleArnseither, so it would stayorphaned even after the sweep is enabled. The README now calls that out.
Changes
DnsZoneId/DnsDomain/DnsSweepexplicitly (DNS_ZONE_ID/DNS_DOMAIN/DNS_SWEEP, defaulting to the previous behavior — off), with a commentexplaining the
UsePreviousValuetrap so the next parameter isn't dropped the same way.ROLE_ARNSmust list every account withrecords under the zone (the sweep is per-account, deriving each
{base36}subdomainfrom the account ID); and a verify section that says to confirm
dns-sweep=trueon theinit line rather than assume the feature is live, plus what a sweep hit and a safety
abort look like in the log.
sweepableRecord(): extracted the sweep's in-scope decision, no behavior change.It was inline with the paginated
ListResourceRecordSetscall and therefore untestable,despite being the highest-consequence logic in the sweep — a record wrongly judged
in-scope is a live-DNS outage.
Verification
go test ./...green;sam validatepasses;gofmt/go vetclean.TestSweepableRecordcovers every exclusion: subdomain apex, zone apex, anotheraccount's subdomain, a deceptively similar suffix (
box.evil-5k0zfnmq.spore.host), theUse the AWS account's friendly name (not just base36 account ID) in DNS and elsewhere #121 friendly CNAMEs, and alias A-records. Mutation-checked — removing the alias guard
fails the test.
sweepAccountDNSin dry-run against the livespore.hostzone. For4zlw3a1tit loggedDNS sweep: WOULD delete orphaned A-record win11-test.4zlw3a1t.spore.host -> 13.223.189.34 (no live instance)(
DNSScanned=1 DNSReaped=1), and spared every alias and out-of-account record. Thepartial-scan safety path was confirmed live too: a cross-account
DescribeInstancesdenial logged
aborting sweep for this accountand deleted nothing.Nothing was deleted, and no deploy is included here — enabling the sweep in production is
a separate, explicitly-approved step.
Note on gap (1) of #438
#438 also named "
Cleanupisn't wired to SIGTERM incmd/spored". That is in fact alreadywired —
waitForShutdown()→agent.Cleanup()→DeleteDNSsince 0ea9e39 (2026-06-08),with
TimeoutStopSec=30in the systemd unit. No change needed.