fix: dedupe nameservers to stop duplicate-NS 422 on new zones#54
Closed
ecv wants to merge 2 commits into
Closed
Conversation
New DNSZones failed to program in prod: PowerDNS rejected the default NS RRset PATCH with 422 "duplicate record with content", so zones never reached Accepted/Programmed. Root cause: the DNSZoneClass Static nameserver list carried each nameserver more than once, and nothing on the path deduped it — normalizeStringSlice sorted but kept duplicates, and buildRRSets appended one NS record per entry. Dedupe at three NS-scoped points: - normalizeStringSlice: drop duplicate entries (cleans downstream and upstream Status.Nameservers). - CreateZone: dedupe the apex nameserver list sent at zone creation. - buildRRSets NS case: dedupe by qualified content, which also collapses trailing-dot variants (ns1.example.net vs ns1.example.net.) that only become identical after qualification. Fixes the fleet-wide new-zone failure and unblocks the Integration Chainsaw dns-setup test. Refs: #51 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #53, which is the broader fix: its |
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.
What
Newly-created DNSZones in prod failed to program: PowerDNS rejected the default NS RRset PATCH with
422 "duplicate record with content", so zones never reachedAccepted/Programmed. This blocked every new zone and the infra Integration Chainsawdns-setuptest (#51, Mode 1 — the fleet-wide blocker).Root cause
The
DNSZoneClassNameServerPolicy.Static.Serverslist carried each nameserver more than once, and nothing on the path deduped it:normalizeStringSlicesorted but kept duplicates → doubledStatus.Nameservers(downstream, then mirrored upstream).ensureNSRecordSetemitted one NSRecordEntryper (duplicate) entry.buildRRSetsNS case appended one record per entry → the PATCH carried duplicate NS records → 422.Trailing-dot variants (
ns1.datumdns.netvsns1.datumdns.net.) made it worse: they only collapse to identical content afterqualifyIfNeeded, so a raw-string dedupe alone isn't sufficient.Fix (three NS-scoped dedupe points)
normalizeStringSlice— drop duplicate entries. Cleans both downstream and upstreamStatus.Nameserversat the source (also makes the CR status correct).CreateZone— dedupe the apex nameserver list sent at zone creation.buildRRSetsNS case — dedupe by qualified content, collapsing exact dups and trailing-dot variants right before the PATCH is built. This is the guaranteed 422 fix regardless of what the source list contains.Scope
Mode 1 (duplicate NS) only, per triage. The other two modes from #51 are tracked as sub-issues and a separate PR:
Complementary: #52 surfaces the specific pdns 422 detail into the DNSRecordSet status.
Test
internal/pdns—TestBuildRRSets_NSDedup: exact dup + trailing-dot variant collapse to one record.internal/controller—TestNormalizeStringSlice: duplicates removed.go build ./...clean; affected unit tests pass. (The pdns package's Docker/testcontainers integration test is unrelated and not run here.)Refs #51
🤖 Generated with Claude Code