Skip to content

perf(k8s): mount the uv-seed cache in the runner Job #7072

Backlog

Description

@devops-cli-service

Split from #4814.

Problem, the uv-seed image holds a filled uv cache at /cache and a /seed.json record. The runner Job does not mount it, so the first uv child still starts with an empty cache and takes 30 to 101 s. ## Why deferred, the admission policy k8s/devops/roadmap-service/admissionpolicy.yaml limits the volumes and mounts of the runner Job. It admits the tmp and home emptyDirs, the named runner emptyDirs, the config ConfigMap and the planner repo PVC. The homelab cluster runs Kubernetes 1.31 (k8s/README.md), and no test or decision shows that it serves an image volume. A person must also set the uv-seed GHCR package to public, as the service and mcp-server packages are. ## Acceptance criteria, the admission policy admits an image volume for the runner Job and a read-only mount at /opt/uv-seed in the prepare and agent containers. bootstrap_checkout copies /opt/uv-seed/cache into UV_CACHE_DIR when _seed_fits accepts /opt/uv-seed/seed.json, before the first uv child. The first uv child of an implement Job ends in under 30 s on a live cluster run. The uv-seed package is public.

Proposed design

Problem statement

The uv-seed image holds a filled uv cache at /cache and a /seed.json record. The runner Job does not mount it. The first uv child starts with an empty cache and takes 30 to 101 s. This change mounts the seed cache in the runner Job and copies it into UV_CACHE_DIR before the first uv child.

Acceptance criteria

Requirement: Admission policy admits the seed image volume

The runner Job admission policy SHALL admit an image volume named uv-seed and a read-only mount at /opt/uv-seed in the prepare and agent containers.

Scenario: Policy admits the seed volume and mounts

  • WHEN uv run devops ci --check --only k8s runs with the updated admission policy and its policy test
  • THEN the command exits 0.

Requirement: Admission policy refuses a writable seed mount

The runner Job admission policy MUST refuse a uv-seed mount that is not read-only.

Scenario: Policy refuses a writable seed mount

  • WHEN uv run devops ci --check --only k8s runs with a policy test that sets a writable uv-seed mount
  • THEN the command exits 0 and its policy test reports Forbidden for the writable mount.

Requirement: bootstrap_checkout copies the accepted seed cache

bootstrap_checkout SHALL copy /opt/uv-seed/cache into UV_CACHE_DIR when _seed_fits accepts /opt/uv-seed/seed.json, before the first uv child.

Scenario: Seed cache is copied before uv runs

  • WHEN uv run pytest tests/roadmap/test_roadmap_runner_tools.py -q runs with a test that sets an accepted seed record and an empty UV cache
  • THEN the test passes and the copied cache files are present before the first uv child starts.

Requirement: bootstrap_checkout skips a rejected seed cache

bootstrap_checkout MUST NOT copy the seed cache when _seed_fits rejects the seed record.

Scenario: Rejected seed cache is not copied

  • WHEN uv run pytest tests/roadmap/test_roadmap_runner_tools.py -q runs with a test that sets a rejected seed record
  • THEN the test passes and UV_CACHE_DIR stays empty.

Requirement: Runner Job mounts the seed volume

The runner Job spec SHALL mount the uv-seed image volume at /opt/uv-seed read-only in the prepare and agent containers.

Scenario: Job spec includes the seed volume and mounts

  • WHEN uv run pytest tests/roadmap/implement/test_roadmap_implement_step.py -q runs with the Job builder
  • THEN the test passes and the built Job has the uv-seed volume and the read-only mounts in prepare and agent.

Requirement: Pending a person after the merge

The first uv child of an implement Job MUST end in under 30 s on a live cluster run after the uv-seed package is public and the cluster serves an image volume.

Scenario: Live implement Job starts uv with the seed cache

  • WHEN a person runs one implement Job on the homelab cluster with the uv-seed package public and the ImageVolume feature gate enabled
  • THEN the job log shows the first uv child ends in under 30 s.

Existing Tool Considered

No alternatives check has run. Kubernetes image volumes cover the read-only mount of the uv-seed image at /opt/uv-seed, and Python shutil.copytree covers the copy into UV_CACHE_DIR. The image volume lacks support on Kubernetes 1.31 unless the ImageVolume feature gate is enabled, and the uv-seed GHCR package must be public.

Key questions

  • Which mechanism mounts the uv-seed cache in the runner Job?: Use a Kubernetes image volume named uv-seed and mount it read-only at /opt/uv-seed in the prepare and agent containers. The cluster does not serve it by default, so the issue waits for the ImageVolume feature gate. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, k8s/README.md]
    • Chosen: Kubernetes image volume. It gives a read-only mount with no copy and no PVC.
    • Rejected: Init container copy to emptyDir. It needs a third init container, a policy change, and a copy tool in the uv-seed image.
    • Rejected: PersistentVolumeClaim. It needs a person to populate and manage the claim.
    • Rejected: Bake the cache into the runner image. It grows the runner image and duplicates the uv-seed image.
  • Which image may the admission policy admit for the uv-seed volume?: Only an image whose reference starts with ghcr.io/dan-petty/devops-cli/uv-seed:, with a tag, or with @, with a digest. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml]
    • Chosen: Restrict to the uv-seed repository. It matches the runner image rule and blocks arbitrary images.
    • Rejected: Admit any image. The policy limits what a Job may run.
  • How does bootstrap_checkout copy the seed cache?: Use shutil.copytree with dirs_exist_ok=True to copy /opt/uv-seed/cache into UV_CACHE_DIR after _seed_fits accepts /opt/uv-seed/seed.json. (best practice) [sources: src/devops_cli/roadmap/runner_tools.py:355, src/devops_cli/roadmap/implement/implement_shell.py]
    • Chosen: shutil.copytree with dirs_exist_ok=True. It is in the standard library, keeps the tree, and accepts an existing target.
    • Rejected: shutil.copy2 for each file. It needs more code and is slower.
    • Rejected: Hardlinks with os.link. The image volume and the emptyDir are different filesystems, so hardlinks fail.
  • Does the admission policy admit the uv-seed volume for stage and planner Jobs?: No. The policy SHALL admit the uv-seed volume only for a runner Job. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml]
    • Chosen: Runner Job only. Only the runner Job runs the uv child.
    • Rejected: All Jobs. It widens the policy for no need.
  • Does the homelab cluster serve an image volume?: No by default. The homelab runs Kubernetes 1.31, and the ImageVolume feature gate is alpha and disabled by default. [sources: k8s/README.md]

Fit

Fits in one pull request.

Suspected block

The homelab cluster must serve an image volume (Kubernetes 1.31 alpha ImageVolume gate), and a person must set the uv-seed GHCR package to public.

Dependencies

None.

Activity

  1. added
    type/infra
    scope/k8s
    source/agent
    on Nov 25, 2026
  2. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    ContributorAuthor
  3. added
    status/new
    value/medium
    effort/medium
    priority/p2-medium
    on Nov 25, 2026
  4. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    ContributorAuthor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

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

    @devops-cli-service
    ContributorAuthor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

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/mediumpriority/p2-mediumscope/k8ssource/agentstatus/newtype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions