Uh oh!
There was an error while loading. Please reload this page.
fix(podman): wait for container stop completion - #2820
Conversation
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
pimlock
commented
Aug 20, 2026
An alternative would be to add an explicit lifecycle epoch (or execution generation) to each sandbox run and have the gateway discard events from older epochs. Conceptually: That would be useful defense in depth, but it is a substantially larger change than this fix. A driver-local counter is not enough: Podman events contain a container ID and timestamps, but no native execution generation. If the driver increments its counter before a delayed epoch-7 event arrives, it could incorrectly tag that old event as epoch 8. Making epochs reliable would require:
The sandbox ID already prevents events from unrelated sandboxes from crossing this boundary. The missing distinction is between two executions of the same retained sandbox/container. For this PR, waiting until Podman reports the previous execution as terminal establishes the required causal boundary and gives the existing |
Label |
pimlock
commented
Aug 20, 2026
@sjenning FYI. I think this makes sense, but I'd love if you could double check. I will merge this, since the fix is quite contained and this helps with the CI, but feel free to propose something different (I explored one alternative and added the comment, but that would be much more involved). |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Wait for Podman to report a sandbox container as fully stopped before allowing the stop operation to complete. This prevents an immediate restart from being regressed to
Errorby the previous container run's delayed exit event.Related Issue
No issue required: this is a localized fix for a confirmed race in the recently added Podman stop/start lifecycle.
Changes
exitedorstopped.stopping.Race
A representative failure followed this sequence:
StopSandboxasked rootless Podman to stop the container.SIGTERMtoSIGKILL.stopping.StartSandbox. Since the prior exit had not completed, the existing event fence had noFinishedAttimestamp to record.die/stopevent from the previous run arrived after the new run enteredStarting. The watcher reported exit code 137 and the gateway changed the sandbox fromStartingtoError.StartSandboxrestarts the same logical sandbox and retained Podman container; it does not create a new sandbox. In compact form, the race is:Waiting for a terminal Podman state closes the gap between steps 3 and 4. The existing timestamp fence can then identify any delayed event from the completed prior run.
Failing jobs
Introduction context
The evidence points to the race being introduced with stop/start itself, rather than by a later regression:
0f8fad23.sandbox_stop_start_preserves_workspaceE2E test was added in that same PR, so there is no test history from before the feature existed.Starting -> Error/ exit-code-137 signature at 16:39 UTC on August 12, shortly after the initial implementation.FinishedAtwas available.The CI history establishes that the race existed in the initial implementation: the new test failed before merge and continued to fail afterward. It does not establish that the failure rate recently increased or that concurrent Branch E2E activity changed its frequency. The observed
SIGTERM-to-SIGKILLpath explains the race window, but the available evidence does not support a broader claim about why failures clustered over time.Testing
mise run pre-commitpassescargo fmt --all -- --checkcargo clippy -p openshell-driver-podman --all-targets -- -D warningscargo test -p openshell-driver-podman(176 passed)sandbox_stop_start_preserves_workspacecovers this path; rootless Podman execution is delegated to CI)Checklist