fix(webhook): scope v1alpha1 DNSRecord webhook to v1alpha1 requests#299
Merged
Merged
Conversation
The vdnsrecord-v1alpha1 validating webhook had no matchPolicy, so it
defaulted to Equivalent: the apiserver converted v1alpha2 DNSRecord
writes to v1alpha1 and routed them through this webhook too. Since the
v2->v1 conversion stamps every record with the v1alpha2-spec annotation
the validator keys on, it rejected the DNS controller's own v1alpha2
auto-record updates ("... cannot be modified via v1alpha1"), looping the
DNS reconcile.
Set matchPolicy=Exact so the webhook only fires for genuine v1alpha1
requests, leaving v1alpha2 controller writes untouched. A v1alpha1-native
edit of a v2-backed record is still blocked (intended — it preserves the
controller-SA reservation on origin=auto and the v2-only data). Reworded
the message/var since it applies to any v2-backed record, not only manual.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
On dev the DNS controller looped on:
even though the controller writes DNSRecords in v1alpha2.
Root cause
vdnsrecord-v1alpha1had nomatchPolicy, so it defaulted to Equivalent. With a multi-version CRD + conversion webhook (storage = v1alpha2), Equivalent makes the apiserver convert v1alpha2 writes down to v1alpha1 and route them through this webhook too. The v2→v1 conversion (ConvertFrom) stamps every record with thesreportal.io/v1alpha2-dnsrecord-specannotation the validator keys on — so the controller's own v1alpha2 auto-record updates were rejected.Fix
Set
matchPolicy=Exacton the v1alpha1 webhook so it only fires for genuine v1alpha1 requests. v1alpha2 controller writes are no longer routed here.origin=auto(a user can't bypass it via the v1alpha1 surface — confirmed by review).manual→backedByV2) since it applies to any v2-backed record, not only manual.Regenerated
config/webhook/manifests.yaml+ helm template (onlymatchPolicy: Exactadded).Test plan
make manifests/make helmregenerated (no parasitic churn)golangci-lintclean🤖 Generated with Claude Code