Skip to content

feat: migrate bootstrap-only validations to CEL - #451

Open
vishnukothakapu wants to merge 1 commit into
kubernetes-sigs:mainfrom
vishnukothakapu:feat/cel-bootstrap-only
Open

feat: migrate bootstrap-only validations to CEL#451
vishnukothakapu wants to merge 1 commit into
kubernetes-sigs:mainfrom
vishnukothakapu:feat/cel-bootstrap-only

Conversation

@vishnukothakapu

Copy link
Copy Markdown
Contributor

Description

This PR completes the migration of the remaining bootstrap-only enforcement validations from the admission webhook to native CEL XValidation markers on the NodeReadinessRuleSpec.

Specifically, it blocks two invalid configurations directly at the API level:

  1. enforcementMode: bootstrap-only combined with defaultStatus
  2. enforcementMode: bootstrap-only combined with conditionPolicy: anyOf

This aligns with the clean hybrid approach established in PR #418, ensuring standard user templates using allOf continue to work while safely short-circuiting unsupported bootstrap-only configurations without the need for a webhook round-trip.

Changes include:

  • Addition of two CEL XValidation markers to nodereadinessrule_types.go
  • Regeneration of the CRD schema
  • Removal of the legacy Go validation logic and associated unit tests from nodereadinessgaterule_webhook.go
  • Addition of mirroring CEL controller envtest test cases
  • Minor documentation update reflecting that the API server (not the webhook) now handles these rejections.

Related Issue

Fixes #449

Type of Change

/kind feature
/kind api-change
/kind cleanup

Testing

  • Automated envtest cases were added to nodereadinessrule_controller_test.go to explicitly verify that the API server rejects these invalid manifests during creation.
  • Webhook unit tests were cleaned up and verified to pass.
  • Manual verification of the generated CRD schema confirmed the CEL markers propagated correctly.

Checklist

  • make test passes
  • make lint passes

Does this PR introduce a user-facing change?

Migrated the remaining `bootstrap-only` validation logic from the admission webhook to native CRD CEL validations, improving API server efficiency when creating or updating NodeReadinessRules.

@kubernetes-prow kubernetes-prow Bot added kind/feature Categorizes issue or PR as related to a new feature. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Aug 24, 2026
@netlify

netlify Bot commented Aug 24, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller canceled.

Name Link
🔨 Latest commit 6115d07
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a8dac3a3b4638000873d446

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 24, 2026
@kubernetes-prow

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@tejassinghbhati

Copy link
Copy Markdown
Contributor

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 accumulate errors across nodeSelector, defaultStatus, and conditionPolicy violations spec, I edit it, so that will conflict.

The one worth knowing about is in should perform comprehensive validation. Your diff leaves this as context.

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.

@yindia

yindia commented Aug 25, 2026

Copy link
Copy Markdown

Same thing I flagged on #455: the chart CRD didn't get regenerated. Both new bootstrap-only rules are in config/crd/bases/ but not in charts/node-readiness-controller/crds/. So verify-chart-drift.sh will fail and Helm installs won't actually enforce them. Could you sync the chart CRD?

Comment thread internal/webhook/nodereadinessgaterule_webhook.go
@vishnukothakapu
vishnukothakapu force-pushed the feat/cel-bootstrap-only branch from 39834ad to 20889e9 Compare August 25, 2026 14:14
@kubernetes-prow kubernetes-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 25, 2026
@vishnukothakapu
vishnukothakapu requested a review from yindia August 25, 2026 14:14
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vishnukothakapu, yindia
Once this PR has been reviewed and has the lgtm label, please assign mrunalp for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Comment thread internal/webhook/nodereadinessgaterule_webhook.go
@vishnukothakapu
vishnukothakapu force-pushed the feat/cel-bootstrap-only branch from 20889e9 to 6115d07 Compare August 25, 2026 14:52
@vishnukothakapu

Copy link
Copy Markdown
Contributor Author

/cc @ajaysundark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate remaining bootstrap-only validations from admission webhook to CEL

3 participants