fix: validate taint value format with CEL - #469
Conversation
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>
✅ Deploy Preview for node-readiness-controller canceled.
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: DsThakurRawat The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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 Regular contributors should join the org to skip this step. 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. |
Description
The CEL validation rules on
spec.taintvalidated the key format and cappedvaluelength at 63 characters, but did not validate the character set ofvalue. 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 withInvalidfrom the API server, landing the node instatus.failedNodeswithEvaluationError. Becausetaint.valueis immutable, the rule could not be repaired in-place and had to be deleted and recreated.This adds a CEL validation rule on
spec.taintmatching the standard Kubernetes label value character set:Empty or omitted values continue to be permitted as before.
Related Issue
Fixes #467
Type of Change
/kind bug
Testing
internal/controller/nodereadinessrule_controller_test.gounderCEL Validation for taint value formatverifying rejection of invalid taint values and acceptance of valid/empty values.test/e2e/taint_validation_test.go.make manifests,make test(exit 0, controller 86.3%), andmake 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 testpassesmake lintpassesDoes this PR introduce a user-facing change?