Skip to content

fix: validate taint value format with CEL - #469

Open
DsThakurRawat wants to merge 1 commit into
kubernetes-sigs:mainfrom
DsThakurRawat:fix/taint-value-validation
Open

fix: validate taint value format with CEL#469
DsThakurRawat wants to merge 1 commit into
kubernetes-sigs:mainfrom
DsThakurRawat:fix/taint-value-validation

Conversation

@DsThakurRawat

Copy link
Copy Markdown
Contributor

Description

The CEL validation rules on spec.taint validated the key format and capped value length at 63 characters, but did not validate the character set of value. Because the API server enforces label value syntax on node taints ((([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?), a rule with an invalid taint value (such as spaces or invalid punctuation) was admitted at CRD validation, but every subsequent node patch failed with Invalid from the API server, landing the node in status.failedNodes with EvaluationError. Because taint.value is immutable, the rule could not be repaired in-place and had to be deleted and recreated.

This adds a CEL validation rule on spec.taint matching the standard Kubernetes label value character set:

rule: '!has(self.value) || self.value.matches(''^(?:(?:[A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$'')'

Empty or omitted values continue to be permitted as before.

Related Issue

Fixes #467

Type of Change

/kind bug

Testing

  • Added unit tests in internal/controller/nodereadinessrule_controller_test.go under CEL Validation for taint value format verifying rejection of invalid taint values and acceptance of valid/empty values.
  • Added e2e test case in test/e2e/taint_validation_test.go.
  • Verified make manifests, make test (exit 0, controller 86.3%), and make lint (0 issues).

This PR was written in part with the assistance of generative AI; the failure was reproduced against envtest and the change was reviewed and tested by hand.

Checklist

  • make test passes
  • make lint passes

Does this PR introduce a user-facing change?

Reject NodeReadinessRules with invalid taint values at admission time rather than failing subsequent node patches with API server validation errors.

The CEL rules on spec.taint validated the key format and capped value
length at 63 characters, but did not validate the character set of
value. A rule with an invalid label value (such as spaces or invalid
characters) was admitted at CRD validation, but every subsequent node
patch failed with Invalid from the API server, causing the node to
land in failedNodes with EvaluationError.

Add a CEL validation rule on spec.taint ensuring that value, when
present, matches standard Kubernetes label value format: alphanumeric,
'-', '_' or '.', starting and ending with an alphanumeric character.

Signed-off-by: Divyansh Rawat <divyanshrawatofficial@gmail.com>
@kubernetes-prow kubernetes-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 13, 2026
@netlify

netlify Bot commented Sep 13, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller canceled.

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

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: DsThakurRawat
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

@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 Sep 13, 2026
@kubernetes-prow

Copy link
Copy Markdown

Hi @DsThakurRawat. 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.

Regular contributors should join the org to skip this step.

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 Sep 13, 2026
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/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it 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.

spec.taint.value is not validated, so a rule the CRD and webhook accept fails every node patch

1 participant