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-11-23: none.
Tool: none found.
Reason: Searches for a CEL type checker or a ValidatingAdmissionPolicy status checker found only schema validators such as kubeconform, which validates OpenAPI schemas and leaves CEL type checks to the API server, so nothing covers the rewrite or the status guard.
Lacks:
- No CEL type check against the Job OpenAPI schema
- No check of status.typeChecking.expressionWarnings
- No rewrite of the resources rule; an in-repo edit
- Offline manifest checks leave server-side validation to kubectl dry-run
Proposed design
Problem statement
The roadmap-service-jobs ValidatingAdmissionPolicy reports CEL type-check warnings on its resource rule. The rule works at run time, but the API server cannot warn about a wrong resource field before the Job reaches the cluster. The change rewrites the rule with map membership checks and adds a live check that fails on status.typeChecking.expressionWarnings.
Acceptance criteria
Requirement: Resources rule type-checks clean
The roadmap-service-jobs policy SHALL report no CEL type-check warnings after the change.
Scenario: Live policy has no expression warnings
- WHEN After the sync, run
kubectl get validatingadmissionpolicy roadmap-service-jobs -o jsonpath='{.status.typeChecking.expressionWarnings}'. - THEN The command prints an empty string.
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 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 the check exits zero.
Existing Tool Considered
The alternatives check of 2026-11-17 in the issue body gives verdict none and names no tool. No open, maintained tool covers this need. The change keeps the in-repo CEL gate test and adds a small live check. 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 resources rule pass the API server type check?: Use the Kubernetes CEL map form. Test each map key with
in, such as'requests' in c.resourcesand'cpu' in c.resources.requests. Keep the value comparisons and the message. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml]- Chosen: Map membership with
in. Kubernetes CEL usesinfor map keys, and it avoids thehas()field check that the type checker reports. - Rejected: Keep
has()on map entries. The live policy reportsundefined field 'requests'andundefined field 'limits'on this form. - Rejected: Bracket access only. It does not remove the need to test map keys and is less readable.
- 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 run where a cluster is available. - 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).