Repository navigation
Description
Problem Description
The ValidatingAdmissionPolicy roadmap-service-jobs (k8s/devops/roadmap-service/admissionpolicy.yaml) has a type-check warning on its resources rule. On 2026-11-13, after the sync of 28db551f6, the policy status shows typeChecking.expressionWarnings on spec.validations[18].expression with "undefined field 'requests'" and "undefined field 'limits'" at each c.resources.requests and c.resources.limits access. Before the sync, the same rule was at index 16 with the same warning.
The rule still works at run time. It applies to every Job that the Service account makes, with failurePolicy: Fail. A run-time error would refuse every runner Job, and the runner Job of 18:20Z was admitted. But the type checker cannot see the rule, so a later edit with a wrong field name would get no warning before it reaches the cluster.
Cause (to confirm)
The CEL type checker of the API server types containers[].resources from the Job OpenAPI schema. It does not find requests and limits as typed fields there, so it reports each access. The other rules of the policy type-check clean.
Proposed Fix
- Write the rule so that the type checker accepts it. For example, test the keys with
'requests' in c.resourcesand'cpu' in c.resources.requestsin place of field access, or use the form of the CEL examples in the Kubernetes documentation for resource maps. - Keep the same allowed values and the same message.
- Add a check that fails when the live policy, or a server dry run of the manifest, reports
typeChecking.expressionWarnings.
Acceptance Criteria
- After the sync,
kubectl get validatingadmissionpolicy roadmap-service-jobs -o jsonpath='{.status.typeChecking}'is empty. - The existing policy tests (
tests/gate/k8s_checks/job_admission_policy.py) pass with the same allowed and refused Job cases. - A test or check refuses a policy manifest whose status has expression warnings.
Alternatives check of 2026-12-01: partly.
Tool: cel-go (https://github.com/google/cel-go), Apache-2.0, last activity 2026-09-10, maintained.
Reason: Searches found no ready-made check for ValidatingAdmissionPolicy status warnings. cel-go supplies the CEL parser and type checker that report the undefined field errors, so it covers only an offline type check of the expressions.
Covers:
- CEL parser and type checker that report undefined field errors
- Same CEL engine family the API server uses
- Go library that compiles policy expressions offline
Lacks:
- No reader of live status typeChecking expressionWarnings
- No Kubernetes Job schema or admission rules
- No Job admission test cases or exit codes
Proposed design
Problem statement
The live roadmap-service-jobs policy reports no CEL type-check warning on its resources rule. The resources rule needs no change. The only warning is on the emptyDir.sizeLimit access in the volume rule. The change rewrites that check with map membership and adds a live check that fails on any expression warning.
Acceptance criteria
Requirement: Pending a person after the merge
The roadmap-service-jobs policy SHALL report no CEL type-check warnings after the sync.
Scenario: Live policy status is clean
- WHEN After the sync, a person runs
uv run devops k8s admission-policy-check. - THEN The command exits 0 and prints no expression warnings.
Requirement: Job admission behavior is unchanged
The policy MUST accept and refuse the same Job cases with the same messages as before the change.
Scenario: Existing gate test passes
- WHEN Run
uv run pytest tests/gate/k8s_checks/job_admission_policy.py. - THEN The command exits 0.
Requirement: Check fails on expression warnings
The admission policy check MUST exit non-zero when the policy status holds a non-empty typeChecking.expressionWarnings.
Scenario: Warning list makes the check fail
- WHEN Run
uv run pytest tests/commands/k8s/test_k8s_admission_policy_check.pywith a mocked non-empty warning list. - THEN The test passes and asserts that the check exits non-zero.
Requirement: Check passes on a clean policy
The admission policy check MUST exit zero when the policy status holds no expression warnings.
Scenario: Empty warning list makes the check pass
- WHEN Run
uv run pytest tests/commands/k8s/test_k8s_admission_policy_check.pywith a mocked empty warning list. - THEN The test passes and asserts that the check exits zero.
Existing Tool Considered
The alternatives check of 2026-11-23 in the issue body gives verdict none and names no tool. No open, maintained tool covers the need. The change adds the in-repo live check that the block says no tool covers. Written cost: about 20k tokens to build, about 3k tokens per later policy change to keep and fix, and about 1 day elapsed.
Key questions
- Which CEL form makes the
emptyDir.sizeLimitcheck pass the API server type check?: Use map membership:'sizeLimit' in v.emptyDirin place ofhas(v.emptyDir.sizeLimit). Keep the rest of the volume rule and its message. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, tests/gate/k8s_checks/job_admission_policy.py]- Chosen: Map membership with
in. The live policy reportsundefined field 'sizeLimit'onhas(v.emptyDir.sizeLimit). Theinoperator tests a map key without field access. - Rejected: Keep
has(v.emptyDir.sizeLimit). The live policy reportsundefined field 'sizeLimit'on this form. - Rejected: Bracket access only. It does not test the key and can error on a missing key.
- Chosen: Map membership with
- Where should the new check that fails on expression warnings live?: Add a live check command
uv run devops k8s admission-policy-checkand unit tests for it. The command reads the policy status withkubectland exits non-zero on a non-emptystatus.typeChecking.expressionWarnings. (best practice) [sources: tests/commands/k8s/test_k8s_searxng_check.py, tests/gate/k8s_checks/job_admission_policy.py]- Chosen: Live check command
devops k8s admission-policy-check. It matches the existingdevops k8s *-checklive checks and can read the live policy status. - Rejected: Extend the offline gate test. The gate test has no cluster and cannot read the live policy status.
- Rejected: Manual
kubectl getonly. It does not fail an automated check.
- Chosen: Live check command
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
#2696 created the admission policy; the candidate fixes a type-check warning in that policy and adds a guard check.dan-petty commentedon Nov 13, 2026
Runtime check on 2026-11-13 at 21:00 UTC, after the sync of #5545 (v0.132.0): the warning of
spec.validations[18](undefined field 'requests'and'limits') is instatus.typeCheckingofroadmap-service-jobs. The rule had the samehas(c.resources.requests)form before #5545, so the stage branch did not cause it.The API server still evaluates the rule at runtime. A server dry-run as the Service (
kubectl --as=system:serviceaccount:devops:roadmap-service -n devops create --dry-run=server) of a stage Job thatbuild_jobmakes from the live CronJobroadmap-stagewas admitted. The same Job with the argsconfig show, and with an extra plain variableDEVOPS_CLI_AI_BASE_URL, was refused by the policy.devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: Searches found only general manifest validators such as kubectl-validate and policy engines such as Kyverno; neither type-checks ValidatingAdmissionPolicy CEL against the Job schema nor fails a check on status.typeChecking expression warnings.
Tool: none found
Lacks:
Searches (10)
Tools considered:
Searches run:
Sources:
A person decides what this check of 2026-11-17 means for the item.
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at 86358b6 (see proposed design in issue body).
dan-petty commentedon Nov 29, 2026
The premise no longer holds on the cluster.
kubectl get validatingadmissionpolicy roadmap-service-jobs -o jsonon v1.37.2+k3s1 (observedGeneration 12) reports zero expression warnings on the resources rule (spec.validations[27].expression), where ResourceRequirements defines requests and limits as typed properties in the OpenAPI v3 schema. The only warning in status.typeChecking.expressionWarnings is on spec.validations[14].expression (has(v.emptyDir.sizeLimit), undefined field 'sizeLimit', added in #5754), so changing the resources rule cannot make status.typeChecking empty as the acceptance criteria require.devops-cli-service commentedon Nov 29, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
dan-petty commentedon Nov 29, 2026
Sub-issue #7713 is addressed in PR #7740 by removing
has(v.emptyDir.sizeLimit)fromk8s/devops/roadmap-service/admissionpolicy.yamlbecause Kubernetes CEL dropsEmptyDirVolumeSource.sizeLimit(oneOf), superseding the'sizeLimit' in v.emptyDirrewrite proposed in the comment thread.devops-cli-service commentedon Dec 1, 2026
The result in the alternatives block of the issue body changed. Before this check:
none, no tool. A person decides what the new result means for the item.Searches (10)
Tools considered:
Searches run:
Sources: