Skip to content

fix(docker): reclaim sandbox token files on out-of-band removal - #3220

Open
letv1nnn wants to merge 1 commit into
NVIDIA:mainfrom
letv1nnn:3041-token-file-not-cleaned-up/letv1nnn
Open

fix(docker): reclaim sandbox token files on out-of-band removal#3220
letv1nnn wants to merge 1 commit into
NVIDIA:mainfrom
letv1nnn:3041-token-file-not-cleaned-up/letv1nnn

Conversation

@letv1nnn

@letv1nnn letv1nnn commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

delete_sandbox_inner skipped per-sandbox token file cleanup on one exit path — Docker reports no container and no in-memory pending record survives — leaving the sandbox's gateway JWT on disk indefinitely. Every other exit path in that function already cleans up. This adds the missing call plus regression coverage.

Related Issue

Fixes #3041

Changes

  • crates/openshell-driver-docker/src/lib.rs: call cleanup_sandbox_token_file_for_delete in the "container gone, no pending record" branch of delete_sandbox_inner.
    • Uses _for_delete rather than _by_id because delete accepts a name with no id (require_sandbox_identifier requires only one of the two). With an empty id, sandbox_token_path resolves to <namespace>/sandbox.jwt, whose parent is the shared namespace directory. _for_delete guards on !sandbox_id.is_empty().
    • Keeps the Ok(false) return: nothing was removed from Docker, so no deletion is claimed and no Deleted watch event fires.
  • crates/openshell-driver-docker/src/tests.rs: two regression tests, plus a loopback stub that answers Docker's GET /containers/json with [] so the branch is reachable without a daemon.
  • crates/openshell-driver-docker/Cargo.toml / Cargo.lock: enable temp-env's async_closure feature. The sync with_vars cannot wrap an async test body, and the tests need XDG_STATE_HOME scoped to a tempdir.

Left alone deliberately: the adjacent summary_container_targetNone branch returns Ok(pending.is_some()) without removing the container. That one is a live container being silently abandoned, not a token leak — adding cleanup there would revoke a running sandbox's credential. Worth its own issue; stop_sandbox_inner handles the identical case with Err(Status::not_found).

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@letv1nnn
letv1nnn marked this pull request as ready for review September 8, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant