Skip to content

fix(api): avoid indexing split() in taint CEL rules for K8s 1.38 cost estimation - #505

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
ajaysundark:fix-crd-cel-cost
Nov 13, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
ajaysundark:fix-crd-cel-cost

Conversation

@ajaysundark

Copy link
Copy Markdown
Contributor

Description

Kubernetes 1.38 upgraded cel-go to v0.33.0, which stops appending @items to the AST path of list indexing expressions when the receiver has an empty path (such as self.key.split('/')). Because Kubernetes's CEL cost estimator returns Elem: nil in the ResultSize of split(), indexing self.key.split('/')[1] receives UnknownSizeEstimate() (MaxUint64), causing .matches() on the indexed element to exceed the CRD validation cost limit (18446744073709551615 > 10000000) and rejecting NodeReadinessRule CRD creation on 1.38 kube-apiserver.

Since the preceding rules on spec.taint already verify that self.key.startsWith('readiness.k8s.io/') (17 characters) and size(self.key.split('/')) == 2, validate the name part length (self.key.size() >= 18 && self.key.size() <= 80) and character set (self.key.matches('^readiness[.]k8s[.]io/[A-Za-z0-9]([-A-Za-z0-9_.]*[A-Za-z0-9])?$')) directly on self.key. This brings the rule costs down to 8 and 5,033,170 (10,380,974 total across spec.taint) and passes Kubernetes 1.38 CRD validation.

Related Issue

None

Type of Change

/kind bug
/kind api-change

Testing

  • Validated the generated config/crd/bases/readiness.node.x-k8s.io_nodereadinessrules.yaml against Kubernetes 1.38 validation.ValidateCustomResourceDefinition (cel-go v0.33.2): 0 validation errors, spec.taint total static estimated cost 10,380,974 (limit 100,000,000).
  • Ran make test, make lint, and make verify.

Checklist

  • make test passes
  • make lint passes

Does this PR introduce a user-facing change?

Fix NodeReadinessRule CRD CEL validation cost overflow on Kubernetes 1.38+ apiservers

Generative AI Usage Disclosure

  • No AI tools were used
  • AI tools were used (complete below)

How they were used:
An AI coding agent diagnosed the cel-go v0.33.0 cost estimation change in api/v1alpha1/nodereadinessrule_types.go, regenerated the CRD manifests, and verified the CRD against Kubernetes 1.38's ValidateCustomResourceDefinition. I reviewed the changes.

@kubernetes-prow kubernetes-prow Bot added kind/bug Categorizes issue or PR as related to a bug. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Nov 13, 2026
@netlify

netlify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

👷 Deploy request for node-readiness-controller pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 23daab8

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ajaysundark

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 13, 2026
@ajaysundark

Copy link
Copy Markdown
Contributor Author

This is a breaking change in K8s-api. I'll followup with upstream.

The fix involves removing the problematic split call in our CEL rules, and handle validation with prefix matching instead to unblock us right away.

/cc @Karthik-K-N

Comment thread api/v1alpha1/nodereadinessrule_types.go Resolved
… estimation

Kubernetes 1.38 upgraded cel-go to v0.33.0, which stops appending @Items to the AST path of list indexing expressions when the receiver has an empty path (such as self.key.split('/')). Because Kubernetes's CEL cost estimator returns Elem: nil in the ResultSize of split(), indexing self.key.split('/')[1] receives UnknownSizeEstimate() (MaxUint64), causing .matches() on the indexed element to exceed the CRD validation cost limit (MaxUint64 > 10,000,000).

Since previous rules already validate that self.key starts with 'readiness.k8s.io/' (17 chars) and has a single '/' separator, validate the name length and character set directly on self.key. This reduces the taint rules' static estimated cost to 10,380,974 and passes Kubernetes 1.38 CRD validation.

Change-Id: I9c02cd527be0c1e29b147ed52eb2123bec20e053

@Karthik-K-N Karthik-K-N 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.

/lgtm

Thank you.

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 13, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit 3569230 into kubernetes-sigs:main Nov 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants