From 8c73cb7a532efafc4560bffe3da8066fb53337af Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 26 Jul 2026 22:01:55 -0500 Subject: [PATCH] fixed HA VM timeout during mm --- defaults.inc | 2 +- inc/evacuate-proxmox-node.sh | 17 +++++++++++++---- tests/test-evacuation.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/defaults.inc b/defaults.inc index ecaf175..c738125 100755 --- a/defaults.inc +++ b/defaults.inc @@ -3,7 +3,7 @@ action="${1:-}" FOLDER='/opt/idssys/ta-proxmenu' -VERS='2026.7.26-8' +VERS='2026.7.26-9' noupdate=' ' diff --git a/inc/evacuate-proxmox-node.sh b/inc/evacuate-proxmox-node.sh index 3afc05d..50a43b2 100644 --- a/inc/evacuate-proxmox-node.sh +++ b/inc/evacuate-proxmox-node.sh @@ -455,6 +455,9 @@ wait_for_ha_evacuation() { local -a ha_ids local -a remaining local guest + local guest_status + local guest_type + local guest_vmid local ha_id log "Waiting for HA-managed guests to leave ${LOCAL_NODE}." @@ -471,8 +474,10 @@ wait_for_ha_evacuation() { remaining=() for guest in "${local_guests[@]}"; do + IFS=$'\x1f' read -r guest_vmid guest_type guest_status _ <<< "$guest" + [[ "$guest_status" == "running" ]] || continue for ha_id in "${ha_ids[@]}"; do - if [[ "${guest%%$'\x1f'*}" == "$ha_id" ]]; then + if [[ "$guest_vmid" == "$ha_id" ]]; then remaining+=("$guest") break fi @@ -842,9 +847,13 @@ main() { policy_nodes policy_strict policy_rule destination route_note <<< "$guest" if guest_is_ha_managed "$vmid"; then - warn "${guest_type} ${vmid} became HA-managed; TAPM will not migrate it manually." - migration_skipped+=("$guest") - continue + status="$(guest_status "$vmid" "$guest_type")" + if [[ "$status" != "stopped" ]]; then + warn "${guest_type} ${vmid} is HA-managed and is not confirmed stopped; TAPM will not migrate it manually." + migration_skipped+=("$guest") + continue + fi + log "${guest_type} ${vmid} is HA-managed but stopped; continuing with offline migration." fi if ! choose_destination "$required_storages" "$policy_nodes" "$policy_strict"; then diff --git a/tests/test-evacuation.sh b/tests/test-evacuation.sh index e999216..665479e 100755 --- a/tests/test-evacuation.sh +++ b/tests/test-evacuation.sh @@ -5,6 +5,37 @@ TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" source "${TEST_ROOT}/tests/testlib.sh" source "${TEST_ROOT}/inc/evacuate-proxmox-node.sh" +test_stopped_ha_guest_does_not_block_wait() { + LOCAL_NODE=node1 + HA_WAIT_SECONDS=0 + get_local_guests() { + printf '%s\n' \ + $'100\x1fqemu\x1fstopped\x1fshutdown-ha-vm\x1f1024' \ + $'101\x1fqemu\x1frunning\x1fnon-ha-vm\x1f1024' + } + get_ha_guest_ids() { + printf '%s\n' 100 + } + wait_for_ha_evacuation +} + +test_running_ha_guest_blocks_wait() { + LOCAL_NODE=node1 + HA_WAIT_SECONDS=0 + get_local_guests() { + printf '%s\n' $'100\x1fqemu\x1frunning\x1frunning-ha-vm\x1f1024' + } + get_ha_guest_ids() { + printf '%s\n' 100 + } + wait_for_ha_evacuation +} + +assert_success "stopped HA guest does not block evacuation wait" \ + test_stopped_ha_guest_does_not_block_wait +assert_failure "running HA guest still blocks evacuation wait" \ + test_running_ha_guest_blocks_wait + set_routing_fixture() { MIGRATION_NODES=(node2 node3) NODE_STORAGE_CACHE=()