Bound the watchdogs' docker calls — a hung daemon is what they exist to catch

This commit is contained in:
Gmer4Lfe
2026-08-24 18:39:59 -04:00
parent 84946ed0c6
commit 049f633667
4 changed files with 14 additions and 7 deletions
+6 -2
View File
@@ -449,7 +449,11 @@ _trap_sys_reboot_restart() {
warn "Exit trap: restarting containers stopped before aborted reboot"
for c in "${_SYS_REBOOT_STOPPED[@]}"; do
[[ -z "$c" ]] && continue
docker inspect "$c" >/dev/null 2>&1 && docker start "$c" >/dev/null 2>&1 || true
# Bounded — this is the aborted-reboot recovery path, running from an EXIT trap. If the
# daemon is wedged (which is a reason a reboot was being attempted), an unbounded call
# here leaves every container it stopped down and the script never exits.
timeout "$DOCKER_TIMEOUT" docker inspect "$c" >/dev/null 2>&1 \
&& timeout "$DOCKER_TIMEOUT" docker start "$c" >/dev/null 2>&1 || true
done
}
@@ -529,7 +533,7 @@ do_reboot() {
warn "Stopping Docker containers..."
if is_docker_enabled && command -v docker >/dev/null 2>&1; then
mapfile -t _SYS_REBOOT_STOPPED < <(docker ps --format '{{.Names}}' 2>/dev/null)
mapfile -t _SYS_REBOOT_STOPPED < <(timeout "$DOCKER_TIMEOUT" docker ps --format '{{.Names}}' 2>/dev/null)
trap _trap_sys_reboot_restart EXIT
timeout 60 docker ps -q 2>/dev/null | xargs -r docker stop >/dev/null 2>&1
fi