Skip to content

feat(roadmap): size the runner Job resources from the plan #3193

Closed

Description

@dan-petty

What happened

The runner Job has one resource class for every item: 2 CPU, 4 Gi of memory requested and 8 Gi at most (k8s/devops/cronjob-runner.yaml). A small item holds the same request as a refactor of 40 files. Issue #3063 asked for requests that follow the plan, and its change left that part out.

What should happen

  • The Service chooses the memory and CPU request of a runner Job from the size of the plan, such as the number of files in its tasks, with a measured table and not a guess.
  • The largest memory limit stays 8 Gi unless a setting raises it.
  • PYTEST_XDIST_AUTO_NUM_WORKERS equals the CPU limit of the Job it is set on. The Service sets both, and a test holds that they agree.
  • The admission policy roadmap-service-jobs allows the sizes that the Service sets, and no more.

Acceptance criteria

  • A plan with few files gets a smaller request than a plan with many files, and a test shows both Jobs.
  • The memory limit of a Job is 8 Gi unless the setting is raised.
  • The CPU limit and the worker count of a Job are equal.
  • The table of sizes cites the measured peak memory of past Jobs.

Related: #3063 (progress-based deadlines).

Alternatives check of 2026-11-05: none.
Tool: none found.

Proposed design

Problem statement

The runner Job uses one resource class for every item: 2 CPU and 4 Gi of memory requested, 8 Gi at most. A small item holds the same request as a large one. The previous plan cited a Job spec builder, a memory-limit setting and an admission policy manifest that the staging commit does not hold; this plan creates them.

Acceptance criteria

Requirement: Plan-size classes

The Service SHALL choose the CPU request, CPU limit and memory request of a runner Job from a table keyed by the plan's file count.

Scenario: Small and large plans

  • WHEN The Service sizes a plan with 3 files and a plan with 60 files.
  • THEN The Job of the 60-file plan requests more CPU and memory than the Job of the 3-file plan, and each matches its table row.

Requirement: Memory limit default

The Service MUST set the memory limit of a runner Job to 8Gi when the setting roadmap.implement.max_memory_limit is unset.

Scenario: Unset limit

  • WHEN The Service creates a Job and the setting is unset.
  • THEN The Job memory limit is 8Gi.

Requirement: Memory limit setting

The Service MUST set the memory limit of a runner Job to the value of roadmap.implement.max_memory_limit when the setting is set.

Scenario: Raised limit

  • WHEN The setting is 12Gi.
  • THEN The Job memory limit is 12Gi.

Requirement: Worker count equals CPU limit

The Service MUST set PYTEST_XDIST_AUTO_NUM_WORKERS to the CPU limit of the runner Job that it creates.

Scenario: Worker count per class

  • WHEN The Service creates a Job whose CPU limit is 4.
  • THEN The Job's PYTEST_XDIST_AUTO_NUM_WORKERS value is 4, and a test checks the equality for every class.

Requirement: Admission allow-list

The admission policy roadmap-service-jobs MUST admit only the CPU request, CPU limit and memory request classes that the size table sets.

Scenario: Off-table class

  • WHEN A Job that the policy selects requests 3 CPU or 7Gi of memory.
  • THEN The policy's allowed sets equal the table's classes, and no other value passes the allow-list.

Requirement: Table provenance

The size table MUST cite the measured peak memory of past runner Jobs that sets each memory request.

Scenario: Table provenance

  • WHEN A test reads the size table.
  • THEN Each row names the measured Job sample and its peak memory.

Requirement: Template default

The runner template MUST keep a PYTEST_XDIST_AUTO_NUM_WORKERS value that equals its CPU limit.

Scenario: Template default

  • WHEN A test reads k8s/devops/cronjob-runner.yaml.
  • THEN The env value equals the CPU limit.

Requirement: Documented override

k8s/README.md MUST state that the Service sets the Job resources and the worker count from the plan.

Scenario: README section

  • WHEN A test reads the runner section of k8s/README.md.
  • THEN The section states the table, the setting and the worker rule.

Existing Tool Considered

No open, maintained tool covers the need. The alternatives check of 2026-11-05 found none. VPA and KRR set requests from observed usage after pods run. They cannot size a Job from its plan before the first run. They cannot set PYTEST_XDIST_AUTO_NUM_WORKERS. They do not write the admission policy. The change builds a two-row table and a Job spec builder. The estimate is 20k tokens to build, 4k tokens each month to keep and fix, and 2 days of elapsed time.

Key questions

  • How does the plan handle the paths that the staging commit does not hold?: The change creates the runner Job spec builder, the roadmap.implement.max_memory_limit setting and the roadmap-service-jobs admission policy manifest. It does not read them as existing files. (best practice) [sources: k8s/README.md, k8s/devops/configmap.example.yaml, k8s/devops/cronjob-runner.yaml]
    • Chosen: Create the missing builder, setting and policy. The body requires the Service to size Jobs and the policy to allow the classes. The staging commit holds no such paths.
    • Rejected: Defer the admission policy part. The body requires the policy allow-list, and one pull request can create it with the builder and the setting.
    • Rejected: Read the missing paths as existing. The staging job returned the item because those paths do not exist at the staging commit.
  • Which measure of the plan sets the runner Job size class?: The number of files in the plan's tasks, in two buckets: at most 10 files, and more than 10 files. (best practice) [sources: k8s/devops/cronjob-runner.yaml, CONTEXT.md]
    • Chosen: Number of files in the tasks. The body names it, and the Service can count it from the plan before the Job starts.
    • Rejected: Number of task groups. One group can hold many files, so two plans with equal groups can differ in size.
    • Rejected: Packed token count. The pack step runs after the Job starts, so the request cannot use it.
    • Rejected: Peak memory of the previous Job. A new plan has no previous Job.
  • Which rows and values does the size table hold?: Small, at most 10 files: CPU request 1, CPU limit 1, memory request 2Gi. Large, more than 10 files: CPU request 4, CPU limit 4, memory request 6Gi. The memory limit is the setting for both rows, 8Gi by default. (best practice) [sources: k8s/devops/cronjob-runner.yaml]
    • Chosen: Two rows from the two measured peaks. 2Gi covers the 1.24 GB peak of the 10 Jobs, and 6Gi covers the 4.13 GB peak of the killed Job.
    • Rejected: Three rows. The repository holds no third measured peak, so the middle row is a guess.
    • Rejected: A formula from the file count. It gives values that no measured point backs and no allow-list can list.
  • Where does the size table live?: A constant in the Service code, next to the runner Job spec builder. A test compares it with the admission policy. (best practice) [sources: k8s/README.md, k8s/devops/cronjob-runner.yaml]
    • Chosen: Constant in the Service code. The policy mirrors the table, and one test holds the two equal in one pull request.
    • Rejected: Key in the Service config. A config change would not change the policy, so the policy denies the new class.
    • Rejected: Per-repository setting. The table reflects the size of the cluster node, not one repository.
  • Where does the Service read the memory limit setting?: From the key roadmap.implement.max_memory_limit in the Service config file, with 8Gi as the default. Add the key to k8s/devops/configmap.example.yaml. (best practice) [sources: k8s/devops/configmap.example.yaml, k8s/devops/cronjob-runner.yaml, CONTEXT.md]
    • Chosen: Service config key. The Service already reads DEVOPS_CLI_CONFIG, and roadmap.implement.in_runner sets the same name pattern.
    • Rejected: Environment variable on the deployment. It puts one setting in a second place.
    • Rejected: Per-repository .github/roadmap.toml. The limit protects the cluster node, not one repository.
    • Rejected: Hard-coded 8Gi. The body asks for a setting that raises the limit.
  • How does the Service set the resources and the worker env on the Job?: The Service builds the Job spec from the CronJob template. It overrides resources and the PYTEST_XDIST_AUTO_NUM_WORKERS value before it creates the Job. (best practice) [sources: k8s/README.md, k8s/devops/cronjob-runner.yaml, src/devops_cli/core/process.py]
    • Chosen: Override the spec before create. The admission policy sees the final spec, and no second write races the policy.
    • Rejected: Patch the Job after create. The policy admits the template size first, and a patch can be denied after the Job exists.
    • Rejected: Add flags to devops k8s run-job. The Service calls the API, and a CLI flag adds a process between the Service and the cluster.
  • How does the admission policy roadmap-service-jobs express the allowed sizes when the staging commit has no policy manifest?: Create a ValidatingAdmissionPolicy and its binding in this change. The CEL allow-list names the table's CPU request, CPU limit and memory request classes. It does not constrain the memory limit, so the setting can raise it. (best practice) [sources: k8s/README.md, k8s/devops/cronjob-runner.yaml]
    • Chosen: Create a CEL allow-list that mirrors the table. It admits exactly the request and CPU limit classes the Service sets and denies every other value.
    • Rejected: Defer the policy part. The body requires the policy allow-list, and one pull request can create it.
    • Rejected: LimitRange with a default and a maximum. A LimitRange cannot deny a request above the table, and it cannot check the env.
    • Rejected: Keep no policy. It then admits sizes that the Service never sets.
  • Does the runner template keep its current 2 CPU and 4Gi values?: Yes. The template keeps 2 CPU and 4Gi as the default of a manual run. The Service always overrides it, and the policy selects only the Jobs that the Service creates. (best practice) [sources: k8s/devops/cronjob-runner.yaml, k8s/README.md]
    • Chosen: Keep 2 CPU and 4Gi. A manual Job needs a valid default, and the policy does not select it.
    • Rejected: Set the template to the small row. A manual run for a large plan then starts too small.
    • Rejected: Remove the resources from the template. A manual Job would then get no request.
  • What does the runner template set today?: The template sets 2 CPU request and limit, 4Gi memory request, 8Gi memory limit, and PYTEST_XDIST_AUTO_NUM_WORKERS=2. [sources: k8s/devops/cronjob-runner.yaml]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 2, 2026
  2. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The system runs correctly today; this reduces waste and prevents over-provisioning but does not block delivery.
    • Value: Medium. Sizing requests to the plan cuts idle resource cost and aligns worker count with CPU, but the Jobs already complete.
    • Effort: Medium. Requires a measured size table, Service logic, an admission policy update, and tests for both small and large plans.
    • Related: feat(roadmap): long-running tasks: progress-based deadlines instead of a fixed two hours #3063, which asks for a different change. Both concern runner Job configuration; #3063 delivers progress-based deadlines while the candidate delivers plan-sized CPU and memory requests.
  3. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at fd09aa4 (see proposed design in issue body).

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

    @devops-cli-service
    Contributor

    The stage job returned the item to New. The premise of the issue does not hold at the staging commit, so the job planned no change and opened no pull request.

    Evidence:

    The premise holds. But the plan cannot be written as asked: the staging commit does not hold the paths that the issue's design needs. probes says "The path k8s/devops/roadmap-service/admissionpolicy.yaml ..." is not listed, and the context shows no admissionpolicy.yaml, no roadmap Service Job-spec builder, and no setting roadmap.implement.max_memory_limit: "The path roadmap.implement.max_memory_limit is no file of the staging commit. No commit in the history deleted or renamed it." The change is one pull request of planning only, so it needs no premise failure.

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

    @devops-cli-service
    Contributor

    Alternatives check: none

    Tool: none found

    Lacks:

    • No tool chooses a runner Job's CPU and memory request from the plan's file count before the Job runs; VPA and KRR recommend from observed usage after pods have run.
    • No tool sets PYTEST_XDIST_AUTO_NUM_WORKERS to the CPU limit of the Job it creates.
    • No tool writes or narrows the roadmap-service-jobs admission policy allow-list to match a plan-size table.
    • No tool supplies the measured-peak provenance table, the roadmap.implement.max_memory_limit setting, or the runner template and README checks.

    Searches run:

    • tool to size Kubernetes Job CPU memory requests from estimated workload
    • Vertical Pod Autoscaler Kubernetes Jobs resource requests measured usage
    • Goldilocks KRR Kubernetes resource recommendation tool measured usage
    • Kubernetes operator choose pod resources based on job input size file count

    Sources:

    Checked on 2026-11-05. A person decides what this means for the item. The check changes no label and closes no issue.

  8. added
    status/ready
    and removed
    status/new
    on Nov 5, 2026
  9. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at d254410 (see proposed design in issue body).

  10. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 6, 2026
  11. removed
    status/in-review
    owner/agent
    on Nov 6, 2026
  12. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor
  13. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 22:09 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/mediumpriority/p2-mediumscope/roadmaptype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions