diff --git a/defaults.inc b/defaults.inc index cf839e4..2b582ad 100755 --- a/defaults.inc +++ b/defaults.inc @@ -3,7 +3,7 @@ action="${1:-}" FOLDER='/opt/idssys/ta-proxmenu' -VERS='2026.7.25-12' +VERS='2026.7.25-13' noupdate=' ' diff --git a/inc/evacuate-proxmox-node.sh b/inc/evacuate-proxmox-node.sh index 516dfba..2a893b4 100755 --- a/inc/evacuate-proxmox-node.sh +++ b/inc/evacuate-proxmox-node.sh @@ -6,6 +6,7 @@ set -u # Guests with local storage remain on this node and are gracefully shut down. HA_WAIT_SECONDS=300 +MAINTENANCE_WAIT_SECONDS=60 SHUTDOWN_TIMEOUT=180 LOCAL_NODE="$(hostname -s)" @@ -248,11 +249,29 @@ guest_status() { fi } -if ! ha-manager status | - grep -F "$LOCAL_NODE" | - grep -q "maintenance mode"; then - die "${LOCAL_NODE} is not in HA maintenance mode." -fi +wait_for_maintenance_mode() { + local deadline=$((SECONDS + MAINTENANCE_WAIT_SECONDS)) + + log "Waiting for ${LOCAL_NODE} to enter HA maintenance mode." + + while true; do + if ha-manager status | + grep -F "$LOCAL_NODE" | + grep -q "maintenance mode"; then + printf '\n' + return + fi + + if (( SECONDS >= deadline )); then + die "${LOCAL_NODE} did not enter HA maintenance mode within ${MAINTENANCE_WAIT_SECONDS} seconds." + fi + + printf '\r Waiting for HA maintenance mode... ' + sleep 2 + done +} + +wait_for_maintenance_mode wait_for_ha_evacuation || die "Resolve the remaining HA guests before continuing the evacuation."