Skip to content

fix(k8s): Job policy emptyDir sizeLimit fails CEL type check #7713

Done

Description

@dan-petty

Problem Description

The live ValidatingAdmissionPolicy roadmap-service-jobs (k8s/devops/roadmap-service/admissionpolicy.yaml) has a CEL type-check warning in status.typeChecking.expressionWarnings on spec.validations[14].expression:

undefined field 'sizeLimit' at has(v.emptyDir.sizeLimit) (added for planner emptyDir volumes in #5754).

In the Kubernetes OpenAPI v3 schema (v1.37.2+k3s1), io.k8s.api.core.v1.EmptyDirVolumeSource.sizeLimit uses allOf referencing Quantity, which uses oneOf (string or number). The API server CEL schema converter drops fields with oneOf, so has(v.emptyDir.sizeLimit) reports undefined field 'sizeLimit'.

Reproduction Steps

  1. Run kubectl get validatingadmissionpolicy roadmap-service-jobs -o jsonpath='{.status.typeChecking}' against the cluster (v1.37.2+k3s1).
  2. Observe expressionWarnings on spec.validations[14].expression naming undefined field 'sizeLimit'.

Expected vs Actual Behavior

Expected: roadmap-service-jobs passes CEL type checking with empty status.typeChecking.expressionWarnings.

Actual: status.typeChecking.expressionWarnings holds undefined field 'sizeLimit' on spec.validations[14].expression.

Environment Diagnostics

  • Cluster Kubernetes version: v1.37.2+k3s1
  • Policy observedGeneration: 12

Logs, Traces, or Terminal Output

{"expressionWarnings":[{"fieldRef":"spec.validations[14].expression","warning":"batch/v1, Kind=Job: ERROR: <input>:1:172: undefined field 'sizeLimit'"}]}

Source

Source: #5548

Alternatives check of 2026-11-29: none.
Tool: none found.
Reason: Searches found no linter or library that rewrites ValidatingAdmissionPolicy CEL for the Kubernetes schema drop of EmptyDirVolumeSource.sizeLimit; cel-go only evaluates CEL and Kyverno is a separate policy engine, so the fix is a manifest edit.

Lacks:

  • Removal of the unsupported sizeLimit reference from the policy expression
  • Empty status.typeChecking.expressionWarnings on the live policy
  • Gate test admitting planner tmp and home emptyDir volumes without sizeLimit

Proposed design

Problem statement

The live ValidatingAdmissionPolicy roadmap-service-jobs reports a CEL type-check warning on has(v.emptyDir.sizeLimit). Kubernetes CEL drops EmptyDirVolumeSource.sizeLimit because Quantity uses oneOf. The policy must stop referencing sizeLimit so status.typeChecking.expressionWarnings is empty. The planner template already sets the 512Mi limit.

Acceptance criteria

Requirement: Planner volume rule has no sizeLimit check

The roadmap-service-jobs ValidatingAdmissionPolicy SHALL admit a planner Job that has tmp and home emptyDir volumes with no sizeLimit.

Scenario: Planner Job without sizeLimit is admitted

  • WHEN uv run pytest tests/gate/k8s_checks/job_admission_policy.py runs.
  • THEN The command exits 0 and all tests pass.

Requirement: Kubernetes manifest checks pass

The updated k8s/devops/roadmap-service/admissionpolicy.yaml SHALL pass the Kubernetes manifest checks.

Scenario: Kubernetes check passes

  • WHEN uv run devops ci --check --only k8s runs on the change.
  • THEN The command exits 0 with no k8s check failure.

Requirement: Pending a person after the merge

The live roadmap-service-jobs policy SHALL report no CEL expression warnings after the merge.

Scenario: Live policy type check has no expression warnings

  • WHEN A person applies the updated policy to cluster v1.37.2+k3s1 and runs kubectl get validatingadmissionpolicy roadmap-service-jobs -o jsonpath='{.status.typeChecking.expressionWarnings}'.
  • THEN The command prints an empty list.

Existing Tool Considered

The alternatives check in the issue body returned none with no tool. No open, maintained tool or library covers the need. The block gives the reason and the lacks. The change edits an existing Kubernetes ValidatingAdmissionPolicy manifest and builds no code, so no build cost applies.

Key questions

  • How should the policy handle the CEL schema drop of EmptyDirVolumeSource.sizeLimit?: Remove the has(v.emptyDir.sizeLimit) condition from the planner volume rule. Keep the tmp and home emptyDir requirement. Add a comment that CronJob devops-cli-planner-run sets the 512Mi limit because CEL cannot check sizeLimit. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, k8s/devops/roadmap-service/cronjob-planner-run.yaml, tests/gate/k8s_checks/job_admission_policy.py]
    • Chosen: Remove the sizeLimit condition. The CEL schema drops EmptyDirVolumeSource.sizeLimit, so any reference warns. The planner template sets the 512Mi limit.
    • Rejected: Keep the sizeLimit condition and accept the warning. The issue expects empty status.typeChecking.expressionWarnings; the warning would stay.
    • Rejected: Build a custom CEL workaround. Kubernetes CEL has no supported way to read a field that the schema converter drops; a workaround adds code with no reliable schema.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/k8s
    source/agent
    status/new
    value/medium
    effort/low
    on Nov 29, 2026
  2. dan-petty commented on Nov 29, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 29, 2026
  4. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (7)

    Tools considered:

    Searches run:

    • cel-go kubernetes admission policy type check library, results: 5
    • lint Kubernetes ValidatingAdmissionPolicy CEL expressions tool, results: 5
    • Kubernetes ValidatingAdmissionPolicy CEL undefined field sizeLimit Quantity oneOf schema, results: 5
    • ValidatingAdmissionPolicy typeChecking expressionWarnings undefined field, results: 5
    • kubeconform kube-linter validating admission policy manifest validation, results: 5
    • Kyverno policy validation CEL Kubernetes, results: 5
    • kubernetes-sigs validating admission policy linter github, results: 5

    Sources:

  6. added
    status/ready
    and removed
    status/new
    on Nov 29, 2026
  7. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  10. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions