Skip to content

feat: Refuse a zone that overlaps another project's zone - #579

Merged
0xmc merged 8 commits into
mainfrom
feat/zone-claim-admission
Dec 1, 2026
Merged

0xmc merged 8 commits into
mainfrom
feat/zone-claim-admission

Conversation

@0xmc

@0xmc 0xmc commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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

  • A parent and child from two projects admitted at the same moment leave exactly one serving
  • Deleting the serving zone admits the waiting one only after the zone that loses its claim stops serving, in either reconcile order
  • A public suffix and a full claim set are refused with their own reasons
  • CI is green

Fixes #366

0xmc added 4 commits November 29, 2026 15:45
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.
@0xmc
0xmc marked this pull request as ready for review November 29, 2026 21:23
@0xmc
0xmc requested a review from a team as a code owner November 29, 2026 21:23
@0xmc
0xmc enabled auto-merge November 29, 2026 21:23
@0xmc

0xmc commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

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 scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

0xmc added 3 commits November 29, 2026 18:14
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.
@0xmc
0xmc requested a review from scotwells November 30, 2026 17:23

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@0xmc
0xmc requested a review from scotwells November 30, 2026 23:19

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@0xmc
0xmc merged commit 1c93e5d into main Dec 1, 2026
17 checks passed
@0xmc
0xmc deleted the feat/zone-claim-admission branch December 1, 2026 00:58
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.

Refuse zones nested in other projects

2 participants