kvm-host: migrate-vm sets the migration speed automatically
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2647|5|2642|5|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/352//ansiblelint">Evolix » ansible-roles » unstable #352</a> Details
gitea/ansible-roles/pipeline/head This commit looks good Details

This commit is contained in:
Jérémy Lecour 2023-09-17 10:18:37 +02:00 committed by Jérémy Lecour
parent 45fc4b3371
commit 050b2ae419
Signed by: jlecour
SSH Key Fingerprint: SHA256:h+5LgHRKwN9lS0SsdVR5yZPeFlJE4Mt+8UtL4CcP8dY
2 changed files with 25 additions and 2 deletions

View File

@ -33,7 +33,7 @@ The **patch** part changes is incremented if multiple releases happen the same m
* fail2ban: add default variable fail2ban_dbpurgeage_default
* fail2ban: add variable fail2ban_sshd_port to configure sshd port
* metricbeat/logstash: fix Ansible syntax
* kvm-host: release 23.09 for migrate-vm.sh
* kvm-host: release 23.09.1 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)

View File

@ -11,7 +11,7 @@
# * migrate "from"
# * switch to Bash to use local and readonly variables
VERSION="23.09"
VERSION="23.09.1"
show_version() {
cat <<END
@ -84,6 +84,22 @@ check_drbd_sync() {
fi
}
drbd_interface() {
drbd_peer=${1:-}
ip route get "${drbd_peer}" | grep --only-matching --extended-regexp 'dev\s+\S+' | awk '{print $2}'
}
interface_speed() {
interface=${1:-}
file="/sys/class/net/${interface}/speed"
if [ -e "${file}" ]; then
head -n 1 "${file}"
else
# fallback on 1Gb/s if unknown
echo "1000"
fi
}
drbd_peers() {
drbd_config_file=$(drbd_config_file "${1:-}")
@ -210,6 +226,13 @@ migrate_vm_to() {
vm=${1:-}
remote_ip=${2:-}
drbd_interface=$(drbd_interface "${remote_ip}")
interface_speed=$(interface_speed "${drbd_interface}")
migrate_speed=$(echo "${interface_speed}*0.8/8" | bc)
# echo "Migration speed set to ${migrate_speed}MiB/s"
virsh --quiet migrate-setspeed "${vm}" "${migrate_speed}"
export VIRSH_DEFAULT_CONNECT_URI="qemu:///system"
virsh migrate --live --unsafe --verbose "${vm}" "qemu+ssh://${remote_ip}/system" "tcp://${remote_ip}/"
}