Repository navigation
fix(nodes): keep starting containers out of the exited state - #129102
Conversation
`inspectNodeWorkerContainer` read `{{.State.Running}}`, which is false both
before a container starts and after it exits, so the supervisor treated a
container still in `created` as a finished workload. A `status()` poll landing
in the window between spawning `docker start --attach` and the container
entering `running` therefore killed and removed a healthy worker and finalized
its launch as `failed` with exit code 137.
Classify the engine's `{{.State.Status}}` instead: statuses that still own a
workload stay `live`, only finished ones report `dead`. This also tightens
removal verification, which previously accepted a surviving `created` container
as successfully removed.
Verified against Docker 29.4.0: a container reports `created|false` for roughly
the first 100ms after its start client is spawned. The fake engine now models
engine status like a real one, and a regression test holds a container in
`created` until the supervisor inspects it, then asserts the launch stays
running and completes.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 3:36 AM ET / 07:36 UTC. ClawSweeper reviewWhat this changesThe PR classifies Docker-compatible container lifecycle status instead of a running boolean so a newly created worker container remains live during startup status polling. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open: this focused repair corrects a source-visible lifecycle race, and no patch correctness defect was found. The PR is member-authored and maintainer-labeled, so it should follow the normal maintainer landing path rather than automated cleanup. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherNode-hosted worker sessions may run in Docker- or Podman-compatible containers. The node-worker supervisor uses container inspection to decide whether a journaled worker remains active or should be finalized and cleaned up. flowchart LR
A[Worker launch request] --> B[Container created and journaled]
B --> C[Engine start request]
C --> D[Supervisor status check]
D --> E[Container lifecycle status]
E --> F[Keep active launch live]
E --> G[Clean up ended launch]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +16, Tests +38. Total +54 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the status-based lifecycle classification after exact-head validation and a short Podman created-to-running smoke if a Podman daemon is available. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: the prior boolean maps a created container to dead, and the added deterministic regression test holds that state until the supervisor polls it. Is this the best way to solve the issue? Yes: interpreting the engine lifecycle state at the inspection owner fixes the ambiguity without retries, sleeps, or downstream compensation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8c5a12c112e6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
|
Rank-up move from the ClawSweeper review — "capture a redacted Podman created-to-running lifecycle smoke" — skipped, with the reason recorded here. The Podman machine on this host has never been started ( Booting a Podman VM and repairing that host's SSH known_hosts is outside the scope of this fix, so the Podman states remain verified from upstream source ( Worth noting the Podman risk is bounded in one direction: the new classification only ever moves a state from |
…w#129102) `inspectNodeWorkerContainer` read `{{.State.Running}}`, which is false both before a container starts and after it exits, so the supervisor treated a container still in `created` as a finished workload. A `status()` poll landing in the window between spawning `docker start --attach` and the container entering `running` therefore killed and removed a healthy worker and finalized its launch as `failed` with exit code 137. Classify the engine's `{{.State.Status}}` instead: statuses that still own a workload stay `live`, only finished ones report `dead`. This also tightens removal verification, which previously accepted a surviving `created` container as successfully removed. Verified against Docker 29.4.0: a container reports `created|false` for roughly the first 100ms after its start client is spawned. The fake engine now models engine status like a real one, and a regression test holds a container in `created` until the supervisor inspects it, then asserts the launch stays running and completes.
What Problem This Solves
Fixes an issue where operators running node-hosted worker sessions with
nodeHost.workerRuns.isolation=containerwould have a healthy worker killed mid-run when anything asked for its status during container startup. The launch ends asfailedwithnode worker failed with exit code 137, and the session dies for no reason the operator can see.The same defect makes
src/node-host/node-worker-supervisor.container.test.tsflaky on CI. It has been failing on loaded Blacksmith shards since #128447 landed, e.g. run 32706072003 and run 32789084018, always asexpected 'failed' to be 'completed'.Why This Change Was Made
inspectNodeWorkerContainerasked the engine for{{.State.Running}}, which isfalsein two unrelated situations: a container that already exited, and one that was created but has not started yet.NodeWorkerSupervisor.status()treatsdeadas proof the workload ended, so it force-removes the container and finalizes the launch. Because the launch path returns as soon as the start client is spawned and the journal is written, any status poll in the startup window destroys a live worker.The fix classifies the engine's
{{.State.Status}}instead of a boolean: statuses that still own a workload (created,initialized,running,paused,restarting,stopping) staylive, finished ones (exited,stopped,dead,removing) reportdead, and anything else remainsunknown. The set members come from Docker's documented container states and Podman's upstreamContainerStatusvalues, since both engines are supported. As a side effect,killNodeWorkerContainer's post-removal verification no longer accepts a survivingcreatedcontainer as successfully removed.Non-goal: no retry, timeout bump, or test-side sleep. The startup window is real and the supervisor now reads it correctly.
User Impact
Container-isolated worker sessions no longer die at random during startup. A status call arriving while the container is still starting returns
runninginstead of killing the worker and recording a bogusfailedreceipt.Evidence
Real engine, not just the test double. Docker 29.4.0 reports the created state as not-running, and the window persists after the start client is spawned:
Pre-fix, that first sample is classified
deadand the supervisor kills the container.Deterministic reproduction. Widening the startup window by 40ms in the fake engine made the existing test fail with the exact CI signature, and a probe on the terminal receipt showed the self-inflicted kill:
With the fix in place, that same 40ms window passes 3/3.
Regression test.
keeps a launch running while its container is still startingholds the container increateduntil the supervisor's own inspect observes it, then asserts the launch is stillrunningand completes. Against the old classification it is the only failing test in the file (13 passed, 1 failed); with the fix the file is 14/14. The fake engine now models engine status rather than a boolean, matching what a real engine reports.Diagnosability. The original assertion compared only
state, so CI printedexpected 'failed' to be 'completed'and discarded the receipt'serrorText, which named the cause. It now usestoMatchObject, so the next failure prints it.Local validation (branch base
49c5bb21c3b):node scripts/run-vitest.mjs src/node-host— 41 files, 561 passed, 2 skippednode scripts/check-changed.mjs— greengpt-5.6-sol, xhigh) — clean, no accepted findingsSize. Production LOC: +20/-4 (net +16) | Tests: +49/-11. The production growth is the closed status classification and the comment explaining why
.State.Runningis not a liveness signal; it encodes an engine contract that cannot be expressed more simply.Not covered. No live proof against Podman; its status strings were verified from upstream
libpod/define/containerstate.gorather than a running daemon.Prior repair for context: #128788 fixed a different cause of the same assertion (partial JSON reads of the fake engine's state file) on 2026-08-24. Sampling failed vitest shard jobs in three one-hour windows after that landed still found 4 hits of this signature out of 25, so this race is the surviving cause.