Skip to content

bug(driver-docker): token file not cleaned up when container is already gone with no pending record #3041

Description

@politerealism

User Story

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

  1. Create a sandbox on the Docker driver.
  2. Remove its container out-of-band (docker rm -f), and ensure enough time/restart passes that the in-memory pending record is gone.
  3. Trigger cleanup (via bug(driver-podman): per-sandbox secrets and volumes are orphaned when a container disappears without DeleteSandbox #2352's fix: a watch deletion event or the prune sweep).
  4. Observe the token file still present on disk.

Environment

Any Docker-driver deployment; not version-specific, this branch predates #2352.

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-neededOpened without agent diagnostics and needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions