Repository navigation
fix: clean up Docker MCP containers after disconnects and crashes - #175107
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8cf5b891ee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs real behavior proof before merge. What this changesThis PR adds exact-container cleanup and dead-process recovery for supported Docker-backed stdio MCP servers. Example: A Docker-backed MCP server exceeds the default 30-second initialization deadline.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep open: this PR addresses a real container leak and preserves main’s probe cleanup reporting, but recovery still repeats work for servers sharing one Docker daemon. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherMCP configuration enters the stdio transport, which launches the Docker client; teardown and startup recovery use container IDs, ownership labels, process identity, and existing state custody to reclaim daemon-owned containers. flowchart TD
A[MCP configuration] --> B[CLI probe or Gateway startup]
B --> C[Docker command recognition]
C --> D[Existing state custody]
D --> E[Docker daemon and container]
E --> F[Exact ID and ownership verification]
F --> G[Container removal and process cleanup]
Technical reviewBest possible solution: Keep exact-container cleanup in the existing stdio lifecycle and coalesce recovery by Docker target while preserving operator configuration. Do we have a high-confidence way to reproduce the issue? Current main confirms host-process-only teardown, the linked report supplies an official-release incident, and the PR records a real CLI timeout reproduction; no target code was executed during this review. Is this the best way to solve the issue? Exact launch identity and retained custody address the daemon-owned resource at its producer; the added parsing, recovery adapter, and lifecycle scenarios serve distinct boundaries, but recovery deduplication needs a narrower target identity. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3020cb46d473. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: No concrete authorization bypass was established, but destructive recovery still needs targeted authority validation. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +893, Tests +100, Docs +23, Config +1, Other +452. Total +1469 across 18 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 18, 2026, 4:37 PM ET / 20:37 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
0969527 to
10e1e7d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10e1e7dd01
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| continue; | ||
| } | ||
| const { env, cwd } = launch.config; | ||
| const key = JSON.stringify([parsed.command, env, cwd]); |
There was a problem hiding this comment.
Deduplicate recovery by Docker target, not the full server environment
When several MCP servers use the same Docker daemon but define different container environment variables such as API tokens, including the entire env object makes every server a separate recovery target. Each target then repeats context/daemon discovery and enumeration, and an unavailable daemon can consume a 10-second command timeout per wave of four while server-startup-bootstrap.ts:468 awaits the whole routine, delaying Gateway startup by minutes for a large registry. Coalesce using only daemon-selection inputs or, more reliably, the resolved daemon identity.
Useful? React with 👍 / 👎.
|
CI classification for rebased head
The last three classifications are based on source and execution-path evidence, not a claimed clean-main reproduction. Comparisons use actual CI merge The run remains failed: 145 successful jobs, 20 skipped, these four failed roots and their aggregate. The additional local package-validation attempt reached its existing 300-second limit before the Docker scenario, so that attempt supplies no passing scenario claim. The completed exact-head CI job supplies the fresh packaged proof. The native landing exception records these failures explicitly. |
|
@clawsweeper re-review Rebased head |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
#175107 added a Docker seed-plan scenario that changes the full-release-validation manifest, leaving the pinned FRV digest in ci-test-runtime-trial stale and the test red on main.
Register the Docker MCP custody scenario/server and macOS source-build verifier as exact Knip entries. Their shell invokers remain live, so retain these proof and packaging boundaries without introducing ignores. Remove the unused cron state fixture after #175975 moved its consumers to the shared regression fixture. Scheduling assertions remain unchanged. Refs: #175107, #176448, #175975. Validation: 79 focused tests, owning cron tsgo, typed lint, formatting, and P2 review pass. Dependency scan clears the requested script findings; unrelated controller and daemon export findings remain.
…enclaw#175107) * fix: reclaim Docker MCP containers on disconnect * fix: preserve uncertain Docker MCP cleanup ownership * fix: observe late Docker MCP container IDs on macOS * fix: settle Docker MCP removal and resolve explicit binaries * fix: inspect active Docker context on older clients * fix: acquire MCP custody before pre-save probes * fix: scope Docker MCP recovery to selected servers
openclaw#175107 added a Docker seed-plan scenario that changes the full-release-validation manifest, leaving the pinned FRV digest in ci-test-runtime-trial stale and the test red on main.
Register the Docker MCP custody scenario/server and macOS source-build verifier as exact Knip entries. Their shell invokers remain live, so retain these proof and packaging boundaries without introducing ignores. Remove the unused cron state fixture after openclaw#175975 moved its consumers to the shared regression fixture. Scheduling assertions remain unchanged. Refs: openclaw#175107, openclaw#176448, openclaw#175975. Validation: 79 focused tests, owning cron tsgo, typed lint, formatting, and P2 review pass. Dependency scan clears the requested script findings; unrelated controller and daemon export findings remain.
Related: #162492
What Problem This Solves
Docker-wrapped stdio MCP servers can leave containers running after initialization times out, a connection closes, or the Gateway dies. Killing the host Docker client does not stop the daemon-owned container.
User Impact
Recognized
docker runcommands and literalsh -c 'exec docker run ...'wrappers receive exact-container cleanup and dead-owner recovery. Ambiguous commands warn and retain their original arguments. Existing unlabeled containers require manual cleanup; recovery inspects only daemons referenced by enabled MCP configuration.Connection deadlines stay unchanged. A pending Docker creation retains its client and state custody until Docker settles. Unconfirmed removal warns and retains ownership so operators can inspect Docker and restart the owning process safely.
Why This Change Was Made
The MCP transport owns a temporary CID file and state, process, and launch labels. It verifies the daemon and labels before exact-ID termination, joining container removal with host-process cleanup. Recovery requires proof that the previous process died. No schema, dependency, public API, or configuration option is added.
Pre-save
addandconfigure --probecommands acquire the existing offline state owner before probing and retain it through cleanup and saving. Named probes recover only their selected definitions, independent Docker targets use bounded concurrency, and CLI changes select the Docker proof lane. Custody flags are never saved in operator configuration.Evidence
0969527e25c88: passed in 68 seconds. Seven lifecycle modes cover close, doctor, add, configure, timeout, literal shell close, and SIGKILL/restart recovery. The same scenario checks missing names, an unrelated unreachable Docker target, exact-ID removal, and unrelated-container preservation.Rebase validation
Rebased onto current main after a conflict in the MCP CLI. Main now owns probing in
mcp-cli-probe.tsand joins cleanup before reporting its outcome. This change preserves that owner and its error reporting, adds selected-server Docker recovery there, and maps that owner to the Docker CI lane. The older formatter-extraction commit was dropped as redundant.The integration review is clean through P2. Scoped lint/format checks and all 12 Docker planner tests pass. Exact-head CI at
10e1e7dd015007c460f1a76b92536303275e85f2completed with 145 successful jobs, 20 skipped, four failed roots and their aggregate. The packaged Docker custody job passed all seven lifecycle modes and negative controls in 71 seconds;security-fastpassed.The MCP cleanup diagnostic-shape failures reproduce on clean main (4 passed, 2 failed). Crabbox cancellation call count, Telegram ingress attempt accounting, and parent-timeout/subagent handoff failures are unrelated by unchanged source and execution paths without Docker MCP servers. These last three are source-based attributions, not claimed main reproductions. The native landing exception preserves all four failures.
The additional local packaging attempt hit the existing 300-second package-validation limit before the scenario ran; no local scenario pass is claimed for that attempt. The exact-head CI job supplies the fresh packaged proof. No assertions or timeouts were changed and no CI rerun was requested merely for green.
Thanks @shing1211 for the detailed report.