update
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
action="${1:-}"
|
action="${1:-}"
|
||||||
FOLDER='/opt/idssys/ta-proxmenu'
|
FOLDER='/opt/idssys/ta-proxmenu'
|
||||||
VERS='2026.7.25-13'
|
VERS='2026.7.25-14'
|
||||||
|
|
||||||
noupdate=' '
|
noupdate=' '
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,12 @@ set -u
|
|||||||
|
|
||||||
HA_WAIT_SECONDS=300
|
HA_WAIT_SECONDS=300
|
||||||
MAINTENANCE_WAIT_SECONDS=60
|
MAINTENANCE_WAIT_SECONDS=60
|
||||||
|
MAX_PARALLEL_MIGRATIONS=3
|
||||||
SHUTDOWN_TIMEOUT=180
|
SHUTDOWN_TIMEOUT=180
|
||||||
LOCAL_NODE="$(hostname -s)"
|
LOCAL_NODE="$(hostname -s)"
|
||||||
|
MIGRATION_LOG_DIR="$(mktemp -d)"
|
||||||
|
|
||||||
|
trap 'rm -rf "$MIGRATION_LOG_DIR"' EXIT
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
printf '\n[%s] %s\n' "$(date '+%F %T')" "$*"
|
printf '\n[%s] %s\n' "$(date '+%F %T')" "$*"
|
||||||
@@ -227,6 +231,39 @@ migrate_guest() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_for_migration_batch() {
|
||||||
|
local index
|
||||||
|
local pid
|
||||||
|
local guest
|
||||||
|
local log_file
|
||||||
|
local vmid
|
||||||
|
local guest_type
|
||||||
|
local status
|
||||||
|
local name
|
||||||
|
|
||||||
|
for index in "${!batch_pids[@]}"; do
|
||||||
|
pid="${batch_pids[$index]}"
|
||||||
|
guest="${batch_guests[$index]}"
|
||||||
|
log_file="${batch_logs[$index]}"
|
||||||
|
IFS=$'\x1f' read -r vmid guest_type status name <<< "$guest"
|
||||||
|
|
||||||
|
if wait "$pid"; then
|
||||||
|
log "Migration completed for ${guest_type} ${vmid} (${name:-unnamed})."
|
||||||
|
else
|
||||||
|
warn "Migration failed for ${guest_type} ${vmid} (${name:-unnamed})."
|
||||||
|
migration_failures+=("$guest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -s "$log_file" ]]; then
|
||||||
|
sed 's/^/ /' "$log_file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
batch_pids=()
|
||||||
|
batch_guests=()
|
||||||
|
batch_logs=()
|
||||||
|
}
|
||||||
|
|
||||||
shutdown_guest() {
|
shutdown_guest() {
|
||||||
local vmid="$1"
|
local vmid="$1"
|
||||||
local guest_type="$2"
|
local guest_type="$2"
|
||||||
@@ -330,15 +367,27 @@ read -r -p "Proceed with shared-storage guest migration? [y/N] " answer
|
|||||||
[[ "$answer" =~ ^[Yy]$ ]] || { echo "Evacuation cancelled."; exit 0; }
|
[[ "$answer" =~ ^[Yy]$ ]] || { echo "Evacuation cancelled."; exit 0; }
|
||||||
|
|
||||||
declare -a migration_failures=()
|
declare -a migration_failures=()
|
||||||
|
declare -a batch_pids=()
|
||||||
|
declare -a batch_guests=()
|
||||||
|
declare -a batch_logs=()
|
||||||
|
|
||||||
for guest in "${shared_guests[@]}"; do
|
for guest in "${shared_guests[@]}"; do
|
||||||
IFS=$'\x1f' read -r vmid guest_type status name <<< "$guest"
|
IFS=$'\x1f' read -r vmid guest_type status name <<< "$guest"
|
||||||
log "Migrating ${guest_type} ${vmid} (${name:-unnamed}) to ${TARGET_NODE}."
|
log "Starting migration for ${guest_type} ${vmid} (${name:-unnamed}) to ${TARGET_NODE}."
|
||||||
if ! migrate_guest "$vmid" "$guest_type" "$status"; then
|
|
||||||
warn "Migration failed for ${guest_type} ${vmid}."
|
log_file="${MIGRATION_LOG_DIR}/${guest_type}-${vmid}.log"
|
||||||
migration_failures+=("$guest")
|
migrate_guest "$vmid" "$guest_type" "$status" >"$log_file" 2>&1 &
|
||||||
|
batch_pids+=("$!")
|
||||||
|
batch_guests+=("$guest")
|
||||||
|
batch_logs+=("$log_file")
|
||||||
|
|
||||||
|
if (( ${#batch_pids[@]} >= MAX_PARALLEL_MIGRATIONS )); then
|
||||||
|
wait_for_migration_batch
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
(( ${#batch_pids[@]} == 0 )) || wait_for_migration_batch
|
||||||
|
|
||||||
declare -a running_local_guests=()
|
declare -a running_local_guests=()
|
||||||
for guest in "${local_guests[@]}"; do
|
for guest in "${local_guests[@]}"; do
|
||||||
IFS=$'\x1f' read -r vmid guest_type status name reason <<< "$guest"
|
IFS=$'\x1f' read -r vmid guest_type status name reason <<< "$guest"
|
||||||
|
|||||||
Reference in New Issue
Block a user