DEVX-155: fix: kill inner dockerd with SIGKILL, use alt socket if alive
Post-merge / detect-and-configure (push) Canceled after 0s
Post-merge / release-and-maintain (push) Canceled after 0s

The inner dockerd started by the CI image doesn't respond to SIGTERM.
Use pkill -9 to force-kill it, then verify it's actually dead by
running docker info. If the old daemon is still alive (can't be killed),
use /dev/shm/docker.sock as an alternate socket path to avoid conflicts.

Also moved the data root cleanup after the kill verification, so we
don't delete files while the old daemon might still be writing to them.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
emil
2026-08-15 01:25:37 +02:00
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent ae33b86ba2
commit 3ac3e613e9
2 changed files with 70 additions and 7 deletions
+27 -7
View File
@@ -223,13 +223,35 @@ def start_docker_daemon(timeout: int = DEFAULT_TIMEOUT) -> bool:
# data root and socket. The inner dockerd uses the container's
# overlay (38G, often 100% full). Killing it frees up the
# socket and any space used by its containers/volumes.
# Use SIGKILL (-9) since the inner dockerd may not respond to SIGTERM.
# Try multiple patterns to match different dockerd invocations.
for pattern in ["dockerd", "dockerd-entrypoint.sh"]:
with contextlib.suppress(Exception):
subprocess.run( # nosec B603 B607
["pkill", "-9", "-f", pattern],
check=False,
timeout=5,
)
time.sleep(3)
# Verify the inner dockerd is actually dead. If we can still
# connect to /var/run/docker.sock, the old daemon is still running
# and we need to use a different socket path.
old_daemon_alive = False
with contextlib.suppress(Exception):
subprocess.run( # nosec B603 B607
["pkill", "-f", "dockerd.*--host fd://"],
check=False,
result = subprocess.run( # nosec B603 B607
["docker", "info"],
env={**os.environ, "DOCKER_HOST": f"unix://{DOCKER_SOCK}"},
capture_output=True,
timeout=5,
)
time.sleep(2)
old_daemon_alive = result.returncode == 0
if old_daemon_alive:
click.echo(" Inner dockerd still alive, using alternate socket")
local_sock = "/dev/shm/docker.sock" # nosec B108
else:
local_sock = DOCKER_SOCK
# Clean up the inner dockerd's data root to free space.
# The inner dockerd stores images, containers, and volumes here.
@@ -243,11 +265,9 @@ def start_docker_daemon(timeout: int = DEFAULT_TIMEOUT) -> bool:
timeout=30,
)
# Use the inner dockerd's socket path (now free after pkill)
# and a fresh data root on the container's overlay.
# Use a fresh data root on the container's overlay.
# /dev/shm is a small tmpfs (16G) — too small for images.
# The container's overlay (38G) has more space after cleanup.
local_sock = DOCKER_SOCK
docker_data_root = "/tmp/docker-data" # nosec B108
# Remove stale socket if present