fix(e2e): stop sandbox leaks from async Drop cleanup - #3750
ericcurtin wants to merge 2 commits into
Conversation
Closes NVIDIA#2922 SandboxGuard::Drop spawned a detached thread to delete the sandbox. The thread got killed with the test process before the delete finished. Switch to a blocking command in Drop, like ManagedCleanup already does. Also wrap two tests' manual cleanup in RAII guards so a panic does not leak a sandbox. Signed-off-by: Eric Curtin <eric.curtin@docker.com>
elezar
left a comment
There was a problem hiding this comment.
The guards should be armed before sandbox creation, using an explicit unique name.
Currently, each guard is constructed only after the create helper returns or after the initial assertions pass. If creation partially succeeds but returns an unexpected status or output, or if name parsing fails, the test panics before installing the guard and still leaks the sandbox.
Please generate the sandbox name first, construct SandboxGuard::manage_existing(name.clone()), and pass that name to sandbox create --name. Since deletion uses allow_missing, dropping the guard when creation never produced a sandbox is a safe no-op.
For example:
let sandbox_name = unique_sandbox_name("canonical-zero");
let _cleanup = SandboxGuard::manage_existing(sandbox_name.clone());
let output = openshell_tty_cmd(&[
"sandbox",
"create",
"--name",
&sandbox_name,
"--",
"echo",
"OK",
])
.output()
.await
.expect("spawn openshell sandbox create");Please apply the same ordering to the label test: its names are already known before create_sandbox_with_labels, so each guard can be installed before its create call. This ensures cleanup covers the assertion and parsing failures that these tests are intended to diagnose.
Address review: install guards with explicit names first. Signed-off-by: Eric Curtin <eric.curtin@docker.com>
|
Addressed: guards are now armed before create with explicit unique names, in both lifecycle tests and the labels test. |
Summary
SandboxGuard::Drop cleaned up via a detached thread that got killed with the test process before the delete finished. Switched to a blocking delete, like ManagedCleanup already does. Also wrapped two tests' manual cleanup in RAII guards.
Related Issue
Closes #2922
Changes
e2e/rust/src/harness/sandbox.rs: synchronous delete in Drop.e2e/rust/tests/sandbox_labels.rs: use SandboxGuard for the four test sandboxes.e2e/rust/tests/sandbox_lifecycle.rs: use SandboxGuard in both canonical-main-exit tests.Testing
cargo test --libine2e/rustmise run pre-commitChecklist
Note: issue #2922 has
state:acceptedbut noagent:implementation-requestedlabel. This is a direct build request, so I proceeded without adding it.