Skip to content

feat: add validation to prevent anyOf misconfiguration - #418

Open
vishnukothakapu wants to merge 3 commits into
kubernetes-sigs:mainfrom
vishnukothakapu:feat/webhook-anyof-defaultstatus
Open

feat: add validation to prevent anyOf misconfiguration#418
vishnukothakapu wants to merge 3 commits into
kubernetes-sigs:mainfrom
vishnukothakapu:feat/webhook-anyof-defaultstatus

Conversation

@vishnukothakapu

@vishnukothakapu vishnukothakapu commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description
This PR adds CEL validation to the CRD to explicitly reject NodeReadinessRule configurations where the conditionPolicy is set to anyOf and any of the defined conditions has a defaultStatus equal to its requiredStatus.

As discussed with @ajaysundark & @AnuragThePathak in PR #315, allowing defaultStatus == requiredStatus within an anyOf rule creates a silent logical short-circuit, causing the rule to be considered satisfied even if the condition is never reported by the Node.

By enforcing this natively via CEL XValidation, we keep the webhook lean while still preventing the misconfiguration. This PR also adds a warning to the concepts documentation.

Related Issue
Fixes #414

Type of Change
/kind feature
/kind documentation

Testing

  • Restructured nodereadinessrule_controller_test.go to include envtest coverage verifying that the API server actively rejects anyOf + defaultStatus configurations via CEL.
  • Verified all Ginkgo test suites pass.

Checklist

  • make test passes
  • make lint passes

Does this PR introduce a user-facing change?

Feature: Added CEL validation to the NodeReadinessRule CRD to reject configurations using `conditionPolicy: anyOf` when a condition's `defaultStatus` is equal to its `requiredStatus`, as this results in a silent evaluation short-circuit.

@kubernetes-prow kubernetes-prow Bot added kind/feature Categorizes issue or PR as related to a new feature. kind/documentation Categorizes issue or PR as related to documentation. labels Aug 17, 2026
@netlify

netlify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller ready!

Name Link
🔨 Latest commit 95c0b0e
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a8890ac8da5d40008e99583
😎 Deploy Preview https://deploy-preview-418--node-readiness-controller.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 17, 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.

@kubernetes-prow kubernetes-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 17, 2026
@vishnukothakapu

Copy link
Copy Markdown
Contributor Author

/assign @ajaysundark

@vitorfloriano

Copy link
Copy Markdown
Contributor

/test pull-node-readiness-controller-junit-report-canary

@kubernetes-prow

Copy link
Copy Markdown

@vishnukothakapu: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/test pull-node-readiness-controller-verify-all

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.

@AvineshTripathi

Copy link
Copy Markdown
Contributor

/ok-to-test

@kubernetes-prow kubernetes-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 17, 2026
Comment thread internal/webhook/nodereadinessgaterule_webhook.go Outdated
Comment thread internal/webhook/nodereadinessgaterule_webhook_test.go Outdated
Comment thread internal/webhook/nodereadinessgaterule_webhook_test.go Outdated
@vishnukothakapu
vishnukothakapu force-pushed the feat/webhook-anyof-defaultstatus branch from faf4a7d to 5fd41e0 Compare August 19, 2026 13:01
@kubernetes-prow kubernetes-prow Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 20, 2026
@vishnukothakapu
vishnukothakapu force-pushed the feat/webhook-anyof-defaultstatus branch from f1b193e to 9d9062b Compare August 20, 2026 13:28
Comment thread internal/webhook/nodereadinessgaterule_webhook_test.go
Comment thread api/v1alpha1/nodereadinessrule_types.go
Comment thread docs/book/src/user-guide/concepts.md Outdated
@ajaysundark

Copy link
Copy Markdown
Contributor

/retitle feat: add validation to prevent anyOf misconfiguration

@kubernetes-prow kubernetes-prow Bot changed the title feat: add webhook validation to prevent anyOf evaluation short-circuit feat: add validation to prevent anyOf misconfiguration Aug 21, 2026
@ajaysundark

Copy link
Copy Markdown
Contributor

@vishnukothakapu please update release notes and description to keep it in sync with the implementation

@vishnukothakapu
vishnukothakapu force-pushed the feat/webhook-anyof-defaultstatus branch from 9d9062b to f85f431 Compare August 21, 2026 07:52
@kubernetes-prow kubernetes-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 21, 2026
@vishnukothakapu
vishnukothakapu force-pushed the feat/webhook-anyof-defaultstatus branch from f85f431 to 2c0f43b Compare August 21, 2026 07:58

@AnuragThePathak AnuragThePathak 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.

Rest LGTM

Comment thread docs/book/src/user-guide/concepts.md Outdated
@vishnukothakapu
vishnukothakapu force-pushed the feat/webhook-anyof-defaultstatus branch from 2c0f43b to 95c0b0e Compare August 21, 2026 17:53

@AnuragThePathak AnuragThePathak 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.

Approving it from my side. @ajaysundark PTAL at your convenience.

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AnuragThePathak, vishnukothakapu
Once this PR has been reviewed and has the lgtm label, please ask for approval from ajaysundark. 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

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/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] anyOf conditionPolicy with defaultStatus == requiredStatus silently short-circuits rule

5 participants