Repository navigation
feat: Refuse a zone that overlaps another project's zone - #579
Conversation
Behind controllers.dnsZoneReplicator.zoneClaims.enabled, default off, the replicator records each zone in its registered domain's ZoneClaimSet and admits it only when the claim evaluates Active. The write is guarded by the resourceVersion it read and retried on conflict, so two zones admitted at once cannot both serve overlapping names. A refused zone reports DNSZoneInUse with a message naming the same-name, parent, child, or duplicate claim, its shadow is deleted, and it retries every minute. A public suffix is refused with InvalidDomain, and a full set with ClaimSetFull. A blocking entry whose zone no longer exists is dropped in the same guarded write, and a deleted zone's entry is released once its shadow is gone. The exact-name ConfigMap is still written and checked first, so turning the flag off admits nothing the old rules would refuse.
A release or a dropped stale claim can demote a zone that is already serving, as when a project's apex goes away and another project's waiting zone in between takes over. Admitted zones now requeue on the claim retry interval while claims are on, so a demoted zone loses its shadow within a minute. The refusal is recorded before the shadow is deleted, and the record set replicator skips record sets of a zone refused for a claim reason, so the downstream finalizer is no longer racing a replicator that recreates every record set it deletes. A blocking zone that cannot be read keeps its claim instead of failing the refused zone's admission. maxEntries is validated only when claims are on.
Admitted zones now requeue every minute, so Admit writes the claim set only when its entries changed, instead of sending an update on every reconcile. The record set replicator skips only zones refused with DNSZoneInUse, the one refusal that deletes the shadow. A zone already serving when it is refused for ClaimSetFull or InvalidDomain keeps its records in sync until the import handles it.
|
Review record. The first pass ran an adversarial reviewer and a conventions reviewer, and both voted merge. A second adversarial pass on Fable held on two bugs. The first was a serving zone demoted by another zone's release that nothing reconciled, so two projects could serve overlapping names. The second was the record set replicator recreating the record sets of a shadow zone being deleted. Both are fixed. Admitted zones now requeue every minute while claims are on, a refusal is recorded before the shadow is deleted, and the record set replicator skips zones refused with DNSZoneInUse. A Fable re-review confirmed every applied fix by tampering with it and voted merge. Follow-ups left open: Reconcile-level tests for the requeue and the record set skip, status on skipped record sets, and sweeping stale entries that do not block anything. Before claims are turned on anywhere, the serving cluster needs the ZoneClaimSet CRD and write access to it, and existing overlaps need the import in #367. |
scotwells
left a comment
There was a problem hiding this comment.
Please correct the DNSZoneInUse guidance: a waiting zone retries automatically and can start serving once the blocking claim is released. Please also test the handoff through the controllers, not just the claim evaluator: the losing zone must be rechecked, its records must not be recreated while it is refused, and the waiting zone must start serving after release.
The handoff test reconciles real DNSZone and DNSRecordSet replicators over fake project and serving clusters: a zone that loses its claim when another project's waiting zone takes over is rechecked and loses its shadow, its record sets are not mirrored while it is refused, and the waiting zone serves once the blocking zone is deleted. Writing it found that a zone refused by the exact-name ledger returned without a requeue even with claims on, so a same-name zone never retried. It now retries every minute while claims are on; with claims off nothing changes.
DNSZoneInUse was described as needing Datum and never clearing. With zone claims on, a refused zone retries every minute and serves once the blocking zone is deleted, and a customer whose own zone blocks it can delete that zone. The catalog now classifies it as the customer's to act on.
The CLI told users a zone refused with DNSZoneInUse would stay refused and should be deleted. It now says the zone can start serving once the other zone is gone, and still shows how to remove it. The catalog entry moves to the ownership section with a remediation that covers zone claims on and off, and a test pins it as the customer's to act on. A test pins that a same-name zone is not retried while claims are off, and the handoff test reconciles a record set three times so a gate regression fails on the mirrored count.
scotwells
left a comment
There was a problem hiding this comment.
The retry guidance is fixed. One handoff issue remains: Release marks the waiting zone active before the demoted zone’s served copy is gone. The new test reconciles the loser first. If the winner reconciles first, it can create its served copy while the other project’s overlapping copy still exists. Please gate serving on confirmed withdrawal of the conflicting copy, and cover the winner-first order in the controller test. The winner should wait while the old copy exists and start serving once it is gone.
A zone that wins a claim after a release now waits, reporting PendingPreviousZoneRemoval and retrying every 10 seconds, while an overlapping zone of another project that lost its claim still has a shadow. The check reads shadows uncached and runs again after the shadow is written, withdrawing it if the zone lost its claim in between. With claims on, admission runs before the exact-name ConfigMap is written, and a refused zone gives up its ConfigMap once its shadow is gone, so a refused zone can't lock the owner out of a name. A claim whose zone is gone is kept while its shadow still exists. The CLI keeps waiting while a new zone reports PendingPreviousZoneRemoval. The test harness stamps creationTimestamp on downstream creates so a zone can be reconciled more than once.
scotwells
left a comment
There was a problem hiding this comment.
Approved with zone claims disabled by default. The winner-first test covers the handoff: the new zone waits until the previous project’s served copy is gone.
Summary
Today a zone is refused only when another project holds the exact same name, so a parent and a child of one domain can be served by two different projects.
With the new zone claims setting on, a zone that overlaps another project's claim is refused with a message naming the conflict, and its served copy is removed until the claim frees up.
A refused zone, including one refused for the exact same name, retries every minute and serves once the blocking zone is deleted and its served copy is gone.
The setting is off by default, and should stay off wherever overlapping zones already exist until #367 imports them.
Test plan
Fixes #366