fix(podman): combine sandbox stop and removal - #2570
Conversation
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
| let (status, bytes) = self | ||
| .request( | ||
| hyper::Method::DELETE, | ||
| &format!("/libpod/containers/{name}?force=true&v=true&timeout={timeout_secs}"), |
There was a problem hiding this comment.
There was a problem hiding this comment.
Note: this documentation is not quite right it turns out. The v param is used for Docker-compatible path, but libpod path needs volumes as a param:
This behavior is present in both the affected Podman 4.9.3 handler and the Podman 6.0.1 handler. OpenShell sends requests to
/libpod/containers/..., sovolumes=trueis the parameter the implementation consumes.
|
Label |
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
Summary
Collapse the Podman driver's separate stop and remove requests into one timed Libpod delete request. Graceful shutdown behavior already existed and is preserved; the change removes the externally scheduled interval between the requests and explicitly applies OpenShell's configured stop timeout to removal.
This mitigates the Podman
type=imagemount lifecycle race observed when one sandbox reaches its stop timeout while another sandbox starts, without globally serializing sandbox lifecycle operations.The change also corrects anonymous-volume removal to use the Libpod endpoint's
volumes=trueparameter. The Docker-compatible endpoint usesv=true; OpenShell calls the Libpod endpoint.Related Issue
Related to the investigation in #2568.
No issue required: this is a localized compatibility fix for the Podman sandbox driver.
Changes
DELETE ...?force=true&volumes=true&timeout=<configured stop timeout>v=trueparameter to the Libpod-specificvolumes=trueparameter.Why
volumes=true, notv=truePodman's generated API documentation currently shows
vforContainerDeleteLibpod, but the server handler distinguishes the two API families:RmOptions.Volumesfrom thevolumesquery parameter.vquery parameter.This behavior is present in both the affected Podman 4.9.3 handler and the Podman 6.0.1 handler. OpenShell sends requests to
/libpod/containers/..., sovolumes=trueis the parameter the implementation consumes.The previous driver sent
v=true, which the Libpod handler ignored. This did not cause the image-mount race, and OpenShell separately removes its named sandbox volume, but it meant the request did not remove anonymous volumes as intended.Reproduction and evidence
The failure was reproduced without OpenShell using:
crun1.14.1ghcr.io/nvidia/openshell/supervisor:02e890ccf1995bf8671a81ec84baf44328b7f5b8The standalone reproducer stopped old containers and started pre-created replacements around the ten-second stop-timeout boundary before removing the old containers. On batch 8, two replacement starts failed because their OCI specifications referenced Podman-owned image-overlay mount sources that no longer existed. The missing paths belonged to the new containers, not the containers being removed.
Starting replacements concurrently with the beginning of immediate teardown did not reproduce across thousands of overlaps. The sensitive window was the transition from stop timeout into final removal.
Changing the lifecycle shape to a single timed forced removal completed 40/40 deliberately timed overlaps without reproducing the missing mount source.
Semantics and confidence
The old and new successful paths both stop a running container gracefully before removal:
POST /stop?t=<configured timeout>, followed byDELETE ?force=trueafter the container stopped.DELETE ?force=true&timeout=<configured timeout>operation; Podman stops the running container and then removes it.The new behavior does not introduce graceful shutdown. It preserves it while eliminating the inter-request scheduling boundary and explicitly applying OpenShell's configured timeout to the forced delete.
The intentional edge-case difference is that the old driver ignored failure from its preliminary stop request. If the container remained running, the subsequent forced removal could make another stop attempt using the container's configured stop timeout, normally ten seconds. The combined operation makes one shutdown attempt with OpenShell's configured timeout and returns its error, avoiding both a possible second timeout period and the inter-request window.
This is an evidence-backed mitigation, not proof that Podman's underlying storage race is impossible:
Testing
mise run pre-commitpassesmise exec -- cargo test -p openshell-driver-podman(135 passed)Checklist