Skip to content

fix(roadmap): read the pod status to find an out-of-memory kill #3727

Description

@dan-petty

Problem or Motivation

The Service continues a runner Job that ended with no result (#3721). It skips the continuation for the failure class oom, because a second run on the same memory limit ends the same way.

The Service finds the class oom only from the log of the Job. It passes an exit status to classify_failure for a stall only (143). It never reads the pod status. A kernel kill of the runner process (OOMKilled, exit status 137) can leave no text in the container log. Then the class is ci_infra, and the Service continues the item two times with the same limit.

The cost is bounded: at most 2 extra Jobs for each item.

Proposed Solution & Architectural Design

  • Read status.containerStatuses[].state.terminated (reason, exitCode) of the pod of the Job when the Service reports a Job that ended.
  • Put the exit status in FailureEvidence.exit_status, so classify_failure gives oom for 137 or the reason OOMKilled.
  • Keep the Role of the Service: it already lists pods.
  • Test first: a pod with OOMKilled and an empty log must give the class oom and no continuation.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

The Kubernetes API (kubernetes client) already gives the container status. No new library is needed. The cost to build is one read of a field and one test, about 30000 tokens.

Proposed design

Problem statement

The Service continues a runner Job that ended with no result. It skips the continuation for the class oom, because a second run on the same memory limit ends the same way. The Service finds oom only from the log of the Job. A kernel kill of the runner process can leave no text in the log, so the class becomes ci_infra and the Service continues the item two times with the same limit. The fix reads the pod status of the Job to find the exit status of a killed container.

Acceptance criteria

Requirement: Pod exit status in the failure evidence

The Service SHALL read the terminated exit status of the container of the Job's pod when it reports a Job that ended, and SHALL pass it to classify_failure.

Scenario: Terminated container with exit status 137

  • WHEN The pod status of the Job holds a terminated container with exit status 137.
  • THEN classify_failure receives exit status 137 in its failure evidence.

Requirement: Class oom from the exit status

classify_failure SHALL return the class oom when the exit status is 137 and the error text is empty.

Scenario: Empty log and exit status 137

  • WHEN The failure evidence holds an empty error text and exit status 137.
  • THEN classify_failure returns oom.

Requirement: No continuation for the class oom

The Service MUST NOT continue an item whose stop has the class oom.

Scenario: OOMKilled pod with no log text

  • WHEN A Job ends with a container killed for memory, its log is empty, and the class oom is recorded.
  • THEN The Service records the stop as job, makes no continuation Job, and the item waits for a retry.

Requirement: Container whose log the Service reads

The Service SHALL read the terminated state of the same container whose log it reads, from state and then from lastState.

Scenario: Restarted container with a terminated last state

  • WHEN The state of the container holds no terminated state and its last state holds exit status 137.
  • THEN The Service passes exit status 137 to classify_failure.

Requirement: No terminated state in the pod status

The Service SHALL keep the class of the log when the pod status holds no terminated state.

Scenario: Pod status without a terminated container

  • WHEN The pod status holds no terminated state for the container and the log holds error text.
  • THEN The Service classifies the failure from the log with no error and records no oom class.

Requirement: Exit status 143 stays a timeout

classify_failure SHALL keep the class timeout for the exit status 143 of a stall.

Scenario: Stalled Job with exit status 143

  • WHEN The Service ends a stalled Job and passes exit status 143.
  • THEN classify_failure returns timeout and not oom.

Existing Tool Considered

No alternatives check has run. The Kubernetes API through the kubernetes Python client already gives the container status, and the Service already holds a client and lists pods. No new library is needed. The written cost to build is one field read in the report path, one rule in classify_failure and their tests: about 30000 tokens, and less than one day.

Key questions

  • Does FailureEvidence already carry the exit status?: Yes. FailureEvidence already holds the exit status, and classify_failure reads it as one of five fields. [sources: openspec/changes/archive/2026-11-02-3065-failure-taxonomy-and-action-table/design.md, src/devops_cli/roadmap/failure.py]
  • How does the Service find the class oom now?: Only a sign in the log gives the class oom. The Service reads no pod status, so a kill with no text in the log becomes ci_infra. [sources: docs/ROADMAP_WORKFLOW.md:156, src/devops_cli/roadmap/failure.py]
  • Does the Service already read the pod of the Job that it reports?: Yes. The implement row reports each Job that ended and reads the last 40 lines of the log of the Job's pod. The same pod read gives the container status. [sources: k8s/README.md:651, docs/ROADMAP_WORKFLOW.md:162]
  • Does the class oom stop a continuation?: Yes. The continue rule needs the action retry in ACTION_BY_CLASS. The class oom has the action raise_limit, so a stop with the class oom gets no continuation Job. [sources: docs/ROADMAP_WORKFLOW.md:156, src/devops_cli/roadmap/failure.py]
  • Which pod status field gives the class oom?: The terminated exit status. The Service passes exit status 137, and classify_failure gives oom for it. An OOM kill always ends the container with exit 137, so the reason needs no separate field. (best practice) [sources: openspec/changes/archive/2026-11-02-3065-failure-taxonomy-and-action-table/design.md, docs/ROADMAP_WORKFLOW.md:156]
    • Chosen: Terminated exit status 137. classify_failure already reads the exit status, and the Service already passes 143 for a stall. An OOM kill ends the container with exit 137.
    • Rejected: Terminated reason OOMKilled in a new evidence field. It widens FailureEvidence for a value that the exit status already states. An OOM kill gives exit 137.
    • Rejected: Log text only. A kernel kill can leave the log empty. That is the defect.
  • Where does the exit status 137 rule go in classify_failure?: Next to the existing exit status 143 rule, before the rules that match text in the log. (best practice) [sources: openspec/changes/archive/2026-11-02-3065-failure-taxonomy-and-action-table/design.md, docs/ROADMAP_WORKFLOW.md:162]
    • Chosen: Rule next to the exit status 143 rule. The order runs from the surest cause. An exit status is sure, and the rule runs before the text rules.
    • Rejected: Rule after the text rules. A text rule can match first and give a class that hides the kill.
    • Rejected: Class passed by the Service at the stop site. The exit status is already an input of classify_failure, and a rule in the pure function is testable offline with no pod.
  • Which container state does the Service read?: The Service reads state.terminated of the container whose log it reads, and lastState.terminated when state holds no terminated state. (best practice) [sources: k8s/README.md:651]
    • Chosen: The container whose log the Service reads, state then lastState. The log and the status must come from one container. A restarted container moves its terminated state to lastState.
    • Rejected: The first container status. The pod can hold more than one container, and the first is not always the runner.
    • Rejected: state.terminated only. A restarted container keeps the kill in lastState, so the Service would miss it.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-08: in-use.
The item already names this tool.
Tool: kubernetes-client/python (https://github.com/kubernetes-client/python), Apache-2.0, last activity 2026-11-06, maintained.

Owner decision 2026-11-13

The approved pipeline split (tracker #5482, Phase 0) divides a killed attempt into classes. This section replaces the requirement "Class oom from the exit status" and its scenario. Exit status 137 alone does not give a class: a Job deadline and an eviction also end with SIGKILL (137) after the grace period.

Read the class of each ended roadmap pod from these signals:

  • oom: the container terminated.reason is OOMKilled.
  • evicted: the pod has the condition DisruptionTarget, or the pod status.reason is Evicted (rollout, node drain, eviction under node memory pressure).
  • deadline: the Job has a condition with the reason DeadlineExceeded.
  • No signal: exit status 137 with no reason stays a typed failure with no kill class.

#5493 and the result lines (#5500) read the class. An oom kill counts against the head, because the attempt spent tokens.

  • A table test: exit status 137 with each signal gives its class, and 137 with no signal gives no kill class.
  • Live proof: after the merge and the release, the result line of each ended roadmap Job pod of the last 7 days holds its class. A comment gives the count of each class.

Activity

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

    @dan-petty
    OwnerAuthor

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

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The cost is bounded to at most two extra Jobs per item, but it wastes runner time and obscures the real failure class.
    • Value: Medium. It stops two wasted Jobs per OOM event and gives the correct failure class for reporting.
    • Effort: Low. The change is one field read from the Kubernetes API and one test, about 30000 tokens.
    • Related: feat(roadmap): a failure taxonomy, and one action for each class #3065, which asks for a different change. Both concern the failure classifier, but #3065 delivered the taxonomy and #3065 is closed; this candidate fixes a gap where the classifier never reads pod status for OOM detection.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

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

  6. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards: this item stays limited to the pod exit status and the class oom.

    The wider fault is that the runner Job returns no typed result to the Service. A Job that leaves the item out exits 0, and the Service guesses from the item status. The issue "feat(roadmap): implement writes a typed result and hands off its log" (part of #3027) owns the typed result implement.result. Do not add the typed result here.

    When both merge, put the exit status of this item into the same FailureEvidence that the Service uses for a Job with no result.

  7. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches surfaced no dedicated OOM-detection tool; the need is a read of the Kubernetes pod container status plus project-specific classification logic. The kubernetes Python client already used by the Service supplies exactly the status read (containerStatuses[].state.terminated / lastState.terminated with reason and exitCode), but it carries no rule mapping exit 137 / OOMKilled to the class oom, no FailureEvidence wiring and no continuation policy, so it covers only part of the issue.

    The item already names this tool.

    Tool: kubernetes-client/python (https://github.com/kubernetes-client/python)

    • License: Apache-2.0
    • Last activity: 2026-11-06
    • Maintained: yes

    Covers:

    • Gives the pod status of a Job, including containerStatuses with state.terminated and lastState.terminated (reason and exitCode), so an OOMKilled container and exit status 137 can be read
    • Already the client the Service uses to list pods and read the Job pod log, so no new library is needed for the read

    Lacks:

    • No classification of the failure: it does not map exit status 137 or the reason OOMKilled to the class oom
    • No passing of the exit status into FailureEvidence or to classify_failure
    • No continuation policy (no continuation Job for the class oom) and no separation of exit 143 timeout from exit 137 oom
    • No test of an OOMKilled pod with an empty log

    Tools considered:

    Searches run:

    • Kubernetes Python client read pod container status terminated exit code OOMKilled, results: 5
    • detect OOMKilled pod exit code 137 library tool, results: 5
    • kubernetes-client python github official Python client for the Kubernetes API, results: 5
    • kubernetes pod status containerStatuses terminated reason OOMKilled exitCode 137, results: 5
    • kube-state-metrics kube_pod_container_status_terminated_reason OOMKilled, results: 5
    • "kubernetes" python package read container terminated state example, results: 5
    • kubernetes-client python, results: 5
    • kube-state-metrics github prometheus exporter cluster state, results: 5

    Sources:

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

  8. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    New case on 2026-11-13, release v0.129.0. The kill is now also given a code class, not only ci_infra.

    • Runner Job devops-cli-runner-20261113-140739-174d, item fix(roadmap): a claim release leaves the item In Progress #5118. The pod state is terminated, reason: OOMKilled, exitCode: 137, at 14:24:28Z. The memory limit is 8Gi.
    • The last tool call in the log was uv run devops ci --only constructs .... No error line comes after it.
    • The Service result line: job=implement item=#5118 result=stopped success=false class=types infra=false repair_rounds=0 tokens=0 seconds=1008.

    So the success measure of the implement job counts a memory kill as a type failure of the code, and the run reports tokens=0 although the agent made many model calls. The fix of this issue (read state.terminated of the pod) also corrects the measure. Please also check that the token count of a killed run comes from the model usage, not from the result file of the Job.

  9. added
    status/in-progress
    and removed
    status/ready
    on Nov 14, 2026
  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 14, 2026
  11. removed
    status/in-review
    on Nov 14, 2026
  12. added a commit that references this issue on Nov 14, 2026
  13. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 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/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions