fix(sandbox-image): restart dockerd until ready in ocm-dockerd-start

On a freshly created session VM dockerd can exit with "timeout waiting for containerd to start" before its first initialization finishes. Supervise dockerd for up to 180s, relaunching it when it exits, instead of failing after 60s. Takes effect once the sandbox image is republished and its digest is pinned.
This commit is contained in:
Chris Scott committed 2026-10-15 16:53:49 -04:00
1 parent 27c673d830
commit 493a51f803
1 file changed
+19 -8
+19 -8
View File
@@ -3,14 +3,22 @@ set -u
lock=/var/run/ocm-dockerd.lock
log=/var/log/dockerd.log
ready_timeout=60
lock_wait=120
ready_timeout=180
lock_wait=240
socket=unix:///var/run/docker.sock
probe() {
timeout 5 env -u DOCKER_HOST -u DOCKER_CONTEXT docker -H "$socket" info >/dev/null 2>&1
}
dockerd_running() {
[ -f /var/run/docker.pid ] && kill -0 "$(cat /var/run/docker.pid)" 2>/dev/null
}
dockerd_alive() {
dockerd_running || pgrep -x dockerd >/dev/null 2>&1
}
probe && exit 0
if [ "$(id -u)" -ne 0 ]; then
@@ -22,15 +30,18 @@ flock -w "$lock_wait" 9 || exit 1
probe && exit 0
if [ -f /var/run/docker.pid ] && kill -0 "$(cat /var/run/docker.pid)" 2>/dev/null; then
:
else
setsid dockerd >"$log" 2>&1 </dev/null 9>&- &
fi
deadline=$(($(date +%s) + ready_timeout))
launched=0
while [ "$(date +%s)" -lt "$deadline" ]; do
probe && exit 0
if ! dockerd_alive; then
if [ "$launched" -eq 0 ]; then
: >"$log"
launched=1
fi
setsid dockerd >>"$log" 2>&1 </dev/null 9>&- &
fi
sleep 1
done