fix: remove empty alternatives from CRD validation patterns - #9462
Conversation
The evictionHard/evictionSoft pattern reads (...)%||(...), where the doubled pipe makes the empty string a valid alternative. An empty value therefore passes admission and reaches resource.MustParse() unparsed, which panics the nodeclass reconciler and stops provisioning while the EC2NodeClass still reports Ready. The volumeSize pattern has the same typo in ([1-9]||...)Ti and ([1-9]||...)T, where a bare "Ti" or "T" passes the pattern; Quantity deserialization rejects it afterwards, so only the schema is wrong there.
|
Hi — friendly ping on this one. I re-checked against current |
Fixes #N/A
Description
The
evictionHard/evictionSoftvalidation pattern contains a doubled pipe:%||makes the empty string a valid alternative, somemory.available: ""passes admission. It then reachesresource.MustParse()with nothing to parse and panics the nodeclass reconciler.The same typo is in the
volumeSizepattern —([1-9]||[1-5][0-7]|58)Tiand([1-9]||[1-5][0-9]|6[0-3]|64)Taccept a bare"Ti"/"T". ThereQuantitydeserialization rejects the value afterwards so nothing crashes, and only the schema is wrong; fixed alongside since it is the same mistake.The pattern is generated by
hack/validation/kubelet.sh, so the fix is applied there and to the two generated copies.How was this change tested?
On a live EKS 1.36 cluster running Karpenter 1.14.0 (
public.ecr.aws/karpenter/controller:1.14.0).Patching a working
EC2NodeClassis accepted:The controller then panics in a loop — 49 panics in the first minute:
{"level":"ERROR","message":"Observed a panic","controller":"nodeclass", "EC2NodeClass":{"name":"default"}, "panic":"cannot parse '': quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'"}Pending pods are never provisioned and no
NodeClaimis created, while theEC2NodeClasskeeps reporting healthy:So the failure is quiet — green status, no provisioning, and the only symptom is in the controller log. Removing the empty value stops the panics immediately (0 in the following 15s), which confirms the cause. The cluster was torn down afterwards.
Also verified against a real API server with the existing CEL suite (
envtest): the added case fails onmainwith "Expected failure, but got no error" and passes with this change, 269/269 green. The corrected pattern still accepts every valid form (10%,100%,0%,500Mi,1Gi,1e9,1.5e+9,+5Gi,-5Gi,.5,5G,100m) and still rejects the invalid ones.Does this change impact docs?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.