Skip to content

feat(k8s): refuse envFrom in each Job of the Service #7076

Backlog

Description

@devops-cli-service

Split from #5498.

ProblemnThe admission policy roadmap-service-jobs admits envFrom for a runner Job. A Job made before the sync of #6520 keeps envFrom, and the Service patches the deadline of a runner Job and resumes a waiting fix-checks Job. The policy checks an UPDATE as a CREATE, so a policy that refuses envFrom would refuse those patches.nnn## Why deferrednThe change waits until no Job with envFrom is left. The deadline cap is 14400 s, plus roadmap.fix_checks.max_wait_minutes for a waiting fix Job. No template of the Service uses envFrom today.nnn## Acceptance criterian- uv run devops ci --check --only k8s passes and the policy check refuses a Job that carries envFrom.n- tests/gate/k8s_checks/job_admission_policy.py fails on a fixture Job with envFrom.n- The Service patches a running runner Job after the policy change and the API server admits the patch. The issue comment gives the Job name and the result.

Proposed design

Problem statement

The policy roadmap-service-jobs must refuse envFrom in each Job of the Service. The Service patches a running runner Job and resumes a waiting fix-checks Job. The policy applies the CREATE rules to an UPDATE. So an envFrom rule refuses the patch of a Job that an old template made. This change refuses envFrom on CREATE only, because a Job keeps its pod template for its life. No wait for the old Jobs is necessary.

Acceptance criteria

Requirement: envFrom refused on create

The policy roadmap-service-jobs SHALL refuse a Job of the Service that carries envFrom in a container when the Service creates it.

Scenario: A new runner Job with envFrom

  • WHEN A fixture runner Job adds envFrom to its agent container.
  • THEN uv run devops ci --check --only k8s passes and the policy returns one refusal whose message names envFrom.

Requirement: envFrom refused in the stage and fix-checks Jobs

The policy SHALL refuse envFrom in the stage Job and in the fix-checks Job, as it does in the runner Job.

Scenario: A stage Job and a fix Job with envFrom

  • WHEN A fixture stage Job and a fixture fix-checks Job each add envFrom to a container.
  • THEN uv run devops ci --check --only k8s passes and the policy returns one refusal that names envFrom for each Job.

Requirement: the deadline patch of a legacy runner Job is admitted

The policy SHALL admit the UPDATE that the Service sends to a runner Job that already carries envFrom.

Scenario: The deadline patch of a legacy runner Job

  • WHEN A fixture runner Job carries envFrom and the Service patches its activeDeadlineSeconds.
  • THEN uv run devops ci --check --only k8s passes and the policy returns no refusal for the UPDATE.

Requirement: the resume of a waiting fix Job is admitted

The policy SHALL admit the UPDATE that resumes a suspended fix-checks Job that carries envFrom.

Scenario: The resume of a legacy fix Job

  • WHEN A fixture fix-checks Job carries envFrom and is suspended, and the Service sets suspend to false.
  • THEN uv run devops ci --check --only k8s passes and the policy returns no refusal for the UPDATE.

Existing Tool Considered

No alternatives check has run. The Kubernetes ValidatingAdmissionPolicy API with CEL covers the need: the repository ships the policy roadmap-service-jobs, and tests/gate/k8s_checks/job_admission_policy.py evaluates each expression offline with cel-expr-python. No new library and no new code are needed. The API server has no offline evaluator, so the gate test supplies one.

Key questions

  • How does the policy refuse envFrom and still admit the patch of a Job that already carries it?: Add request.operation == "CREATE" to the envFrom validation. A Job keeps its pod template for its life. So an UPDATE cannot add envFrom. The Service creates each Job, so no Job with envFrom appears. (best practice) [sources: tests/gate/k8s_checks/job_admission_policy.py]
    • Chosen: CREATE-only guard. A Job's spec.template is immutable, so an UPDATE cannot add envFrom. The guard keeps the CREATE refusal and admits each patch.
    • Rejected: Exempt an UPDATE that keeps the same envFrom. It compares two pod templates and adds no protection over the CREATE-only guard.
    • Rejected: Wait until no Job with envFrom is left. It blocks the item for up to 14400 s plus the fix-checks wait, and it adds no protection.
  • Which Jobs does the policy cover?: The policy matches each Job in namespace devops that the Service account creates. So it covers the runner, the stage and the fix-checks Jobs. The gate test builds each of these Jobs from its template. [sources: tests/gate/k8s_checks/job_admission_policy.py, src/devops_cli/k8s/cluster_job.py]
  • Does the change need a live check on the cluster?: No. The API server runs the same CEL expression that the gate test evaluates with request.operation set to UPDATE. The gate test proves that the patch is admitted. The plan keeps the live check as a task step. (best practice) [sources: tests/gate/k8s_checks/job_admission_policy.py]
    • Chosen: Gate test only. It evaluates the policy expression with the CEL runtime, so it shows the answer of the API server for the same request.
    • Rejected: Live check on a running runner Job. It needs a runner Job on the cluster and gives no answer that the gate test does not give.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/k8s
    source/agent
    status/new
    value/medium
    effort/low
    on Nov 25, 2026
  2. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    ContributorAuthor
  3. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    ContributorAuthor

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

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/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions