Add CEL validation for NodeAddressAutodetection mutual exclusivity#4593
Open
caseydavenport wants to merge 5 commits intotigera:masterfrom
Open
Add CEL validation for NodeAddressAutodetection mutual exclusivity#4593caseydavenport wants to merge 5 commits intotigera:masterfrom
caseydavenport wants to merge 5 commits intotigera:masterfrom
Conversation
The operator's Go webhook already validates that at most one autodetection method is set, but a merge patch can bypass the webhook and set multiple fields simultaneously. Add a CEL XValidation rule directly on the CRD so the API server rejects invalid combinations before the operator ever sees them.
Use size(field) > 0 instead of field != '' to avoid goimports corrupting single quotes in the CEL expression comment. Add a fast unit test that compiles and evaluates the CEL expression against a table of inputs covering all autodetection fields, conflict combinations, and edge cases (false booleans, empty strings/lists).
String fields with omitempty aren't present in the object when unset, so size(self.field) fails with "no such key". Guard each field access with has() to handle absent fields correctly. Replace the cel-go unit test with an envtest-based test that creates real Installation resources against the generated CRD. This validates the full CRD schema including the CEL rules without duplicating the rule expression. Also tests the merge patch scenario that originally motivated the rule.
caseydavenport
commented
Mar 25, 2026
caseydavenport
commented
Mar 25, 2026
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.
The operator's Go webhook validates that at most one autodetection method is set per address family, but a merge patch can bypass the webhook and set multiple fields (e.g.
firstFound: truealongsideinterface: eth0). When this happens, the operator silently picks one and ignores the other, which is confusing.Add a CEL XValidation rule directly on the
NodeAddressAutodetectionstruct so the API server rejects invalid combinations at admission time, before the operator ever sees them.Found this while working on https://github.com/tigera/calico-private/pull/11214 — a merge patch to set
interface: eth0didn't clear the existingfirstFound: true, and the operator kept using first-found.