Repository navigation
Conversation
…rvisor start A sandbox restart starts the workload before its supervisor. Until the supervisor start returns, the supervisor still reports the exit from the previous run. A watcher inspect in that window treated it as a lost supervisor and stopped the new workload with timeout 0, which moved the sandbox from Starting to Error with ContainerExited. Mark the workload and supervisor start as in progress, and report the workload as starting during that window. A missing supervisor, or an exited one outside a start, is still contained. Supervisor events also re-inspected the workload without the previous-exit fence, so a delayed supervisor stop or die from the last StopSandbox could publish the earlier run's exit. Apply the fence to those snapshots too. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix an intermittent Podman driver race: a sandbox restarted with StopSandbox then StartSandbox could go from
StartingtoError(ContainerExited).Related Issue
No issue: localized fix for an intermittent CI failure (failing run, lane
rust-podman-additional-ca).Cause
start_sandboxstarts the workload, then the supervisor, in two API calls. On a restart the supervisor is stillexitedfrom StopSandbox. If the watcher inspects the pair in that gap, it sees a running workload without a running supervisor, treats it as a lost supervisor, and stops the new workload.A related path: a late supervisor
stop/dieevent from StopSandbox could publish the previous run's workload exit, because supervisor events skipped the previous-exit check that workload events already use.Race details
The watcher runs this check on every workload or supervisor event:
On first create the supervisor is
created, which counts as starting, so the check never fires. On a restart, the supervisor is stillexitedfrom StopSandbox.Race 1: the watcher stops the new workload (the CI failure)
Gateway log for sandbox
1a1665c3in the failing run:With the fix,
start_sandboxholds a pair-start guard between the two calls, so an inspect inside that window reportsstartinginstead of stopping the workload.Race 2: a late supervisor event publishes the previous exit
Workload events already drop a snapshot whose exit matches the recorded previous exit. With the fix, supervisor events apply the same check.
Why the guard is safe: the guard exists only in driver memory, and it's dropped on success, error, or cancellation. A missing supervisor, or an exited supervisor outside the driver's own start window (including after a gateway or driver restart), is still contained. The workload doesn't run the agent until the supervisor confirms it.
Changes
driver.rs: both restart paths start the pair throughstart_stopped_pair, which holds a per-sandbox pair-start guard until the supervisor start returns. While the guard is held,inspect_workloadreports a running workload with a not-yet-running supervisor asstartinginstead of stopping it. Containment is unchanged outside that window.watcher.rs: supervisor-triggered snapshots now drop a workload exit that matches the recorded previous exit.Testing
cargo test -p openshell-driver-podmancargo clippy -p openshell-driver-podman --all-targets -- -D warningswatcher.rscover a restart before supervisor start, containment outside a start, and a delayed supervisor event. The first and third fail without the fix.rust-podman*E2E lanes run the affected test.Checklist