fix: watchdog hardening for Unraid 7.3 + Docker 29.x

- Remove dead DOCKER_TIMEOUT=10 from stability_watchdog (daemon check
  is delegated to docker_watchdog; variable was never used post-refactor)
- Fix parity check detection: parity-date.txt is gone in Unraid 7.3;
  now reads mdResync from var.ini (non-zero = check/sync in progress),
  with parity-date.txt fallback for older versions
- Same is_parity_running() fix in docker_watchdog
- DOCKER_TIMEOUT in docker_watchdog now reads WATCHDOG_DAEMON_TIMEOUT
  from master.conf (default 20s) instead of hardcoded 15s
- WATCHDOG_DAEMON_RESTART_WAIT now reads from master.conf
  (default 900s/15min) instead of hardcoded 30s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gmer4Lfe
2026-05-31 19:13:54 -04:00
co-authored by Claude Sonnet 4.6
parent 46b27f609a
commit 4187d52bac
2 changed files with 16 additions and 6 deletions
+9 -4
View File
@@ -262,8 +262,8 @@ validate_unraid_cmd "/usr/local/emhttp/plugins/dynamix/scripts/notify" "
touch "$WATCHDOG_STATE_FILE" "$WATCHDOG_CONTAINER_RESTART_LOG" \
"$DOCKER_WATCHDOG_FAILED_FILE" 2>/dev/null
# Timeout for all docker commands — prevents hung daemon from stalling the watchdog
DOCKER_TIMEOUT=15
# Timeout for all docker commands — configurable via WATCHDOG_DAEMON_TIMEOUT in master.conf
DOCKER_TIMEOUT="${WATCHDOG_DAEMON_TIMEOUT:-20}"
# ==============================================================================================
# ━━━ Status ━━━
@@ -452,7 +452,12 @@ flush_notify() {
}
# Returns 0 if parity check is currently running
# Unraid 7.3+: mdResync in var.ini (non-zero = check/sync in progress)
# Older: parity-date.txt contained "progress" — check both for compatibility
is_parity_running() {
local resync
resync=$(awk -F'"' '/^mdResync=/{print $2}' /var/local/emhttp/var.ini 2>/dev/null)
[[ -n "$resync" && "$resync" != "0" ]] && return 0
grep -q "progress" /var/local/emhttp/parity-date.txt 2>/dev/null
}
@@ -471,8 +476,8 @@ is_parity_running() {
#
# Returns: 0 = daemon healthy | 1 = daemon down, skip this cycle
WATCHDOG_DAEMON_STRIKE_LIMIT=3 # consecutive failed checks before restart attempt
WATCHDOG_DAEMON_RESTART_WAIT=30 # seconds to wait after restart before verifying
WATCHDOG_DAEMON_STRIKE_LIMIT="${WATCHDOG_DAEMON_STRIKE_LIMIT:-3}" # consecutive failed checks before restart attempt (master.conf)
WATCHDOG_DAEMON_RESTART_WAIT="${WATCHDOG_DAEMON_RESTART_WAIT:-900}" # seconds to wait after restart before verifying (master.conf)
# Loaded from state file — persists across single-pass runs
WATCHDOG_DAEMON_STRIKES=$(get_strikes "daemon_strikes" "$WATCHDOG_STATE_FILE")
WATCHDOG_DAEMON_STRIKES="${WATCHDOG_DAEMON_STRIKES//[^0-9]/}"; WATCHDOG_DAEMON_STRIKES="${WATCHDOG_DAEMON_STRIKES:-0}"
+7 -2
View File
@@ -129,7 +129,6 @@ acquire_lock
detect_hosts
TOTAL_CORES=$(nproc)
DOCKER_TIMEOUT=10
SYS_WATCHDOG_REBOOT_WINDOW=$(( SYS_WATCHDOG_REBOOT_WINDOW_HRS * 3600 ))
# Ensure state files exist
@@ -300,7 +299,13 @@ check_abort_conditions() {
fi
fi
if grep -q "progress" /var/local/emhttp/parity-date.txt 2>/dev/null; then
# Unraid 7.3+: parity state is in var.ini (mdResync != 0 means check/sync in progress)
# Older: parity-date.txt contained "progress" — check both for compatibility
_md_resync=$(awk -F'"' '/^mdResync=/{print $2}' /var/local/emhttp/var.ini 2>/dev/null)
_parity_running=false
[[ -n "$_md_resync" && "$_md_resync" != "0" ]] && _parity_running=true
grep -q "progress" /var/local/emhttp/parity-date.txt 2>/dev/null && _parity_running=true
if [[ "$_parity_running" == true ]]; then
if [[ "$SYS_WATCHDOG_ABORT_ON_PARITY" == true ]]; then
error "Parity check running — aborting reboot"
notify "System watchdog aborted reboot on $(hostname) ($MY_ID) — parity running" \