diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de3729a..a584926b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ The **patch** part changes is incremented if multiple releases happen the same m * fail2ban: add default variable fail2ban_dbpurgeage_default * fail2ban: add default variable fail2ban_dbpurgeage_default * fail2ban: add variable fail2ban_sshd_port to configure sshd port -* kvm-host: release 23.08 for migrate-vm.sh +* kvm-host: release 23.09 for migrate-vm.sh * nagios-nrpe: add a NRPE check-local command with completion. * nagios-nrpe: add a proper monitoring plugin for glusterfs (on servers, not for clients) * php: add new variable to disable oveeriding settings of php-fpm default pool (www) diff --git a/kvm-host/files/migrate-vm.sh b/kvm-host/files/migrate-vm.sh index 29a307ce..6803450a 100644 --- a/kvm-host/files/migrate-vm.sh +++ b/kvm-host/files/migrate-vm.sh @@ -11,13 +11,13 @@ # * migrate "from" # * switch to Bash to use local and readonly variables -VERSION="23.08" +VERSION="23.09" show_version() { cat <, +Copyright 2018-2023 Evolix , Jérémy Lecour , Victor Laborie and others. @@ -70,6 +70,20 @@ is_drbd_resource() { test -f "$(drbd_config_file "${resource}")" && drbdadm role "${resource}" >/dev/null 2>&1 } +check_drbd_sync() { + resource=${1:-} + + set +e + dstate=$(drbdadm dstate "${resource}" | grep -vF 'UpToDate/UpToDate') + cstate=$(drbdadm cstate "${resource}" | grep -vF 'Connected') + set -e + + if [ -n "${dstate}" ] || [ -n "${cstate}" ]; then + echo "DRBD resource ${resource} is not up-to-date" >&2 + exit 1 + fi +} + drbd_peers() { drbd_config_file=$(drbd_config_file "${1:-}") @@ -227,6 +241,8 @@ migrate_to() { echo "Start migration of ${vm} to ${remote_ip} (${remote_host})" + check_drbd_sync "${resource}" + set_drbd_role primary "${resource}" "${remote_ip}" migrate_vm_to "${vm}" "${remote_ip}" set_drbd_role secondary "${resource}"