Repository navigation
fix(sandbox): remove the worker container in Delete - #778
sresarehumantoo wants to merge 1 commit into
Conversation
|
Reproduced the bug on main and checked the fix against a real Docker Engine (27.5.1):
Heads-up: #764 also rewrites |
|
Closing as a duplicate of #764, which is merged. #764's Delete path removes the worker and keeps the task entry when removal fails, and it also covers workers left behind by failed execs, timeouts, cancelled streams and truncated demux responses, with the cleanup mutex. Merging both would leave a second, dead removeContainer block in Delete and contradictory cleanup tests. If #778 has a case #764 misses, say which one and reopen with a focused test. |
Follow-up to #737.
Problem
DockerBackend.Deleteno longer removes the worker container. The worker stays running and attached to the task network, so the network delete fails andDeletereturns an error:Because
Deletenow keeps the task entry until every resource is proven gone, each retry hits the same error.server_mgmt.gologs the error and deletes the task anyway, so the worker container and task network are left behind. The uid 10001 processes are still killed by the proc scan, so this is a resource leak, not a surviving agent process.Cause
49c4511 (#737) rewrote
Delete(sandbox/docker.go) to callkillCaptured. WhenkillWorkerByProcScansucceeds,killCapturedreturns nil and intentionally leaves the worker running soKill(pause) can reuse it. The previousDeletefollowedKillwithb.removeContainer(ctx, tc.workerID); that line was dropped in the rewrite, so the worker is only removed on the proc-scan failure fallback.Fix
After
killCaptured,Deleteremoves the worker container the same way it removes the proxy: the error is joined, andworkerIDis cleared viaclearWorkerIDonly once removal is proven. The worker goes before the network, and the task stays in the map for retry on any failure.Killis unchanged.Tests
TestDeleteRemovesWorkerBeforeNetwork: Delete issuesDELETE /containers/worker-1beforeDELETE /networks/artex-task-t1.TestDeleteKeepsStateWhenWorkerRemovalFails: a 500 on the worker delete returns an error and keeps the task andworkerID.Both fail on main and pass with this change. The existing fake Docker tests missed the bug because none asserted a worker DELETE after a successful kill.
The Docker e2e is opt-in and not run in CI, which is how this got through. With
artex-worker:localandartex-egress-proxy:localbuilt from this branch:On main the same run fails at the Delete step with the error above.
go build ./...,go vet ./...,gofmt -l .(clean) andgo test ./...pass.