You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(driver-docker): token file not cleaned up when container is already gone with no pending record #3041
As an operator running OpenShell with the Docker compute driver, I want a sandbox's per-sandbox token file removed whenever its resources are reclaimed — including when the container was already removed out-of-band — so that credential material doesn't accumulate indefinitely on disk.
Problem Statement
In crates/openshell-driver-docker/src/lib.rs's delete_sandbox_inner, when find_managed_container_summary finds no container and there's no in-memory pending record for the sandbox, the function returns Ok(false) immediately without calling the token-file cleanup. Every other branch in this function (found container, or a pending record with no live container) does call the cleanup. This is the one gap.
Impact / Why This Matters
#2352 fixed the server-side gap where out-of-band sandbox removal never triggered a DeleteSandbox call at all. Now that it does, Docker's own DeleteSandbox implementation needs to be idempotent-complete for that fix to actually close Docker's leak — right now it isn't, for this specific branch. The result: a sandbox's token file can still leak indefinitely when its container disappears out-of-band and the in-memory pending-record has already expired or was never populated (e.g. after a gateway restart).
Acceptance Criteria
delete_sandbox_inner calls the token-file cleanup in the "container gone, no pending record" branch, matching the other branches.
Regression test covering this specific branch.
Reproduction Steps
Create a sandbox on the Docker driver.
Remove its container out-of-band (docker rm -f), and ensure enough time/restart passes that the in-memory pending record is gone.
delete_sandbox_inner in crates/openshell-driver-docker/src/lib.rs (~line 1042-1105): when find_managed_container_summary returns None (no live container) and remove_pending_sandbox also returns None (no in-memory pending record), execution falls through to return Ok(false); at line 1081 with no call to any token-cleanup function. Every other exit path in this function (live container found, or pending record present with container gone) calls cleanup_sandbox_token_file / cleanup_sandbox_token_file_for_delete before returning. cleanup_sandbox_token_file_by_id(sandbox_id, config) (line 2695) already supports id-only cleanup with no dependency on a PendingSandboxRecord, so the fix is a straightforward added call before the Ok(false) return — no new plumbing required. Related to #2352 (closed), which fixed the server-side gap so out-of-band container removal now reaches DeleteSandbox at all; this issue is the one remaining Docker-side branch that isn't idempotent-complete for that fix to fully close the leak.
Impact Signals
Affected users/scope: Docker-driver deployments only; triggered when a container is removed out-of-band (e.g. docker rm -f) after the in-memory pending record has expired or the gateway has restarted.
Workaround: None found; token file persists on disk until manual cleanup.
Evidence quality: High — exact code path and missing call confirmed by reading the function directly; no reproduction run needed given the code is unambiguous.
Human Decision Required
Decide whether OpenShell should address this issue. If yes, apply state:accepted, associate it with a roadmap item, or do both, and decide
whether the work remains human-owned. Either action records acceptance;
roadmap placement additionally records sequencing.
To queue investigation or planning for an unattended agent, also apply agent:plan-requested. You can instead directly ask an agent to use create-spike or build-from-issue on this issue; the agent will warn about
missing expected workflow labels and continue without changing them. If no,
close it as not planned and record the rationale.
Note: I do not have permission to update labels on this repo (state:triage-needed → state:validated, add area:compute). A maintainer needs to apply these manually.
Activity
letv1nnn commentedon Sep 8, 2026
letv1nnn commentedon Sep 8, 2026
Hey @politerealism, I'd like to take this one.
politerealism commentedon Sep 8, 2026
Sounds good tome!