local sandbox: recreate a parked container whose docker network is gone - #848
Open
irisfeng wants to merge 1 commit into
Open
local sandbox: recreate a parked container whose docker network is gone#848irisfeng wants to merge 1 commit into
irisfeng wants to merge 1 commit into
Conversation
Docker containers record the network they were created with by ID. When that network is removed out-of-band (daemon restart with a changed address pool, a manual network prune), a parked sandbox container can never start again: docker start fails with 'network <id> not found' and the raw error surfaces to the user on their next session. Before reusing a stopped container, check that the networks it still references exist; when one is gone, fall through to the existing recreate path, which removes the container and runs a fresh one on a newly created network. The per-scope home volume is remounted, so no user data is lost. Give the scratch path the same guard plus the rm its fall-through previously never needed (reaching it used to imply the container was gone).
Author
|
Friendly ping for review — happy to adjust scope or split the change if that helps. The failure mode (a parked container whose docker network was reclaimed) hits any deployment that prunes networks, and the PR ships with tests covering the exact user-facing error. Anything needed from my side to move it forward? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Each local-sandbox container runs on its own docker network and is parked (
docker stop) between turns. Docker records that network in the container's endpoint config by ID. If the network is removed out-of-band while the container is parked — a manualdocker network prune, a daemon restart that loses networks — the container can never start again:ensureContainer/ensureScratchsaw a stopped container with a matching image and went straight todocker start, which throws that error verbatim on every subsequent session. The only recovery was removing the container by hand. Recreating the network under the same name does not help, because the stored endpoint references the old network ID.Fix
Before reusing a stopped container, verify the networks it still references exist (
networksIntact: inspect the endpoint map, check eachNetworkID). When one is gone, fall through to the existing recreate path —rm -f+docker runon a freshly created network. That path remounts the per-scope named volume, so home-directory data survives. Running containers short-circuit past the check (their networks cannot be pruned out from under them).The scratch path gets the same guard, plus the
rm -fits fall-through previously never needed (reaching it used to imply the container did not exist).Deliberately unchanged:
ensureRunning(restart under a live handle) still surfaces the rawdocker starterror. That scenario implies the daemon died mid-session — execs fail regardless — and every new session enters throughprovision, where the guard now breaks the wedge permanently.Tests
Two new cases (scoped + scratch): park a container, delete its network, provision again → container recreated on a fresh network, same volume remounted, warm home (
coldStart: false). The fake docker now models the failure mode itself —startfails with the "network not found" daemon error when the endpoint's network is missing — so both tests fail on the base commit with exactly the user-facing error this PR fixes, and pass with it. Fulltest/local-sandbox.test.tssuite passes (20/20), tsc and oxlint clean.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.