feat(docker-nuke): add timeout-bounded daemon health check

This commit is contained in:
David Ibia
2026-07-19 23:22:03 +01:00
parent ca256661b8
commit 49380dc87d
2 changed files with 66 additions and 1 deletions
+8 -1
View File
@@ -14,7 +14,6 @@ set -euo pipefail
# hiding a genuinely dead variable added later. By the final task none of these
# directives should remain.
# shellcheck disable=SC2034
HEALTH_TIMEOUT=6 # seconds to wait on `docker info` before calling it wedged
# shellcheck disable=SC2034
GRACEFUL_WAIT=8 # seconds to let Docker quit politely
@@ -133,6 +132,14 @@ docker_pids() {
done
}
# Returns 0 if the daemon answers within HEALTH_TIMEOUT, else non-zero
# (124 specifically means it hung rather than errored).
docker_healthy() {
local rc=0
run_timeout "$HEALTH_TIMEOUT" docker info >/dev/null 2>&1 || rc=$?
return "$rc"
}
log() { printf '%s\n' "$*"; }
warn() { printf '%s\n' "$*" >&2; }