test: guard CEL balance and the immutable Job template before merge #168
Loading…
Reference in a new issue
No description provided.
Delete branch "test/admission-cel-and-job-template-guards"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Trunk
18db1c1ffailed to deploy twice (flux_deployment_failed, both rolled back to0a1d98a0) and blocked every seanfarm release until96d9dd02repaired it. Two defects, both invisible to every guard intests/check.sh:)short inbinjovi-untrusted-credential-guardvariables[3]. The apiserver compiles CEL at apply time only, so the error surfaced as a failedkyverno-policiesKustomization after the release had started.binjovi-forgejo-integration-v14Job template changed under the same name. A Job template is immutable, so thebinjoviKustomization failed.Change
tests/vap-cel-balance.sh(wired intotests/check.sh): yq lists every CEL expression (matchConditions,variables,validationsand theirmessageExpression,auditAnnotations,mutations) of everyValidatingAdmissionPolicyandMutatingAdmissionPolicyunderkubernetes/; a stdlib-only python lexer (the admission image has no PyYAML) checks that( [ {close in order and that strings terminate ('…',"…", triple quotes,r'…'raw). It checks itself against a broken and a whole fixture before it judges the repository, and zero policies or zero expressions is a failure. 64 expressions in 6 policies today, 0.7 s.Against the trunk defect it says:
tests/binjovi.shpins acksumfingerprint of the current Job template (yq -o=json -I=0 'select(.kind == "Job") | .spec.template'). When the template changes, the guard fails and tells the editor to bump the generation in the four places and record the new fingerprint. The fingerprint is identical under the gate image's yq v4.53.2 and local v4.53.3. The retired-generation loop now covers v1–v13.This is not a CEL compiler; it catches the unbalanced-bracket and open-string class, which is what a hand-edited multi-line expression gets wrong.
tests/check.shis green locally (47 s) and insidebinjovi-gitops-validator:v5(2 m 30 s); both new checks were run red against the exact trunk defects first.https://claude.ai/code/session_01LeVatedQ4sCA1u6LHjo7B5