feat: migrate bootstrap-only validations to CEL - #451
Conversation
✅ Deploy Preview for node-readiness-controller ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi @vishnukothakapu. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Heads up on a collision with #455, which migrates the nodeSelector check to CEL. Different constraint to yours, but we overlap on four files. Two concrete spots. You delete the The one worth knowing about is in Expect(allErrs).To(HaveLen(1)) // Empty nodeSelector validation
Expect(allErrs[0].Field).To(Equal("spec.nodeSelector"))That holds today but stops holding once #455 removes the empty check from the webhook, so whichever of ours merges second needs that repointed at an unparseable selector rather than an empty one. Happy to rebase mine on yours if you land first, no preference. |
|
Same thing I flagged on #455: the chart CRD didn't get regenerated. Both new bootstrap-only rules are in |
39834ad to
20889e9
Compare
20889e9 to
6115d07
Compare
|
/cc @ajaysundark |
|
/ok-to-test |
|
/ok-to-test |
6115d07 to
4a22f0c
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ajaysundark, vishnukothakapu, yindia The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
An empty nodeSelector matches every Node in the cluster, so a rule carrying one applies its taint fleet wide. The only thing stopping that today is validateSpec in the validating webhook, and the webhook is optional and off by default, so the guard is absent on a default install. That gap is what kubernetes-sigs#403 documented from the chart side. Move the constraint onto the CRD as CEL, where it applies on every cluster regardless of whether the webhook is deployed. This continues the migration described in kubernetes-sigs#449, and does not overlap kubernetes-sigs#451, which covers the two bootstrap-only constraints. CEL cannot express whether a selector parses, so the LabelSelectorAsSelector error check stays in the webhook. The empty check is removed rather than left alongside it: CRD validation runs before validating webhooks, so that branch is now unreachable. An absent nodeSelector is still caught by the required marker rather than by CEL, because the field is omitempty/omitzero and serialises away. Both reject the object, they just report it differently, and the tests cover each path. Signed-off-by: tejassinghbhati <tejassinghbhati077@gmail.com>
An empty nodeSelector matches every Node in the cluster, so a rule carrying one applies its taint fleet wide. The only thing stopping that today is validateSpec in the validating webhook, and the webhook is optional and off by default, so the guard is absent on a default install. That gap is what kubernetes-sigs#403 documented from the chart side. Move the constraint onto the CRD as CEL, where it applies on every cluster regardless of whether the webhook is deployed. This continues the migration described in kubernetes-sigs#449, and does not overlap kubernetes-sigs#451, which covers the two bootstrap-only constraints. CEL cannot express whether a selector parses, so the LabelSelectorAsSelector error check stays in the webhook. The empty check is removed rather than left alongside it: CRD validation runs before validating webhooks, so that branch is now unreachable. An absent nodeSelector is still caught by the required marker rather than by CEL, because the field is omitempty/omitzero and serialises away. Both reject the object, they just report it differently, and the tests cover each path. Signed-off-by: tejassinghbhati <tejassinghbhati077@gmail.com>
Description
This PR completes the migration of the remaining
bootstrap-onlyenforcement validations from the admission webhook to native CELXValidationmarkers on theNodeReadinessRuleSpec.Specifically, it blocks two invalid configurations directly at the API level:
enforcementMode: bootstrap-onlycombined withdefaultStatusenforcementMode: bootstrap-onlycombined withconditionPolicy: anyOfThis aligns with the clean hybrid approach established in PR #418, ensuring standard user templates using
allOfcontinue to work while safely short-circuiting unsupported bootstrap-only configurations without the need for a webhook round-trip.Changes include:
XValidationmarkers tonodereadinessrule_types.gonodereadinessgaterule_webhook.goenvtesttest casesRelated Issue
Fixes #449
Type of Change
/kind feature
/kind api-change
/kind cleanup
Testing
envtestcases were added tonodereadinessrule_controller_test.goto explicitly verify that the API server rejects these invalid manifests during creation.Checklist
make testpassesmake lintpassesDoes this PR introduce a user-facing change?