diff --git a/02_configure_host.sh b/02_configure_host.sh index d22fb3586..0fa7542b3 100755 --- a/02_configure_host.sh +++ b/02_configure_host.sh @@ -243,3 +243,13 @@ if [ "$DISABLE_MULTICAST" == "true" ]; then sudo ebtables -A OUTPUT --pkttype-type multicast -p ip6 --ip6-dst ${dst} -j DROP done fi + +# Hack to force use of infinite leases in versions of libvirt that don't +# support setting the lease time in the network config. +# This should be removed when we have a new enough version of libvirt to +# do it properly. I believe any version 6.3.0 or above should have the feature. +if [ ${INFINITE_LEASES:-0} -eq 1 ] +then + ./infinite-leases.sh & + echo "$!" > "${WORKING_DIR}/infinite-lease-pid" +fi diff --git a/host_cleanup.sh b/host_cleanup.sh index 99c4e51ec..a3ab65f92 100755 --- a/host_cleanup.sh +++ b/host_cleanup.sh @@ -60,3 +60,9 @@ sudo ebtables --flush # Kill any lingering proxy sudo pkill -f oc.*proxy + +# Kill the infinite lease script +if [ -s "${WORKING_DIR}/infinite-lease-pid" ]; then + kill $(cat "${WORKING_DIR}/infinite-lease-pid") + rm "${WORKING_DIR}/infinite-lease-pid" +fi diff --git a/infinite-leases.sh b/infinite-leases.sh new file mode 100755 index 000000000..744af6edd --- /dev/null +++ b/infinite-leases.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +NETWORK_NAME=${CLUSTER_NAME}bm +FILENAME=/var/lib/libvirt/dnsmasq/${NETWORK_NAME}.hostsfile + +# We need to keep running even after setting the infinite leases because +# they are overwritten multiple times in the deployment process. +while : +do + if grep -q -v infinite $FILENAME + then + sudo perl -pi -e 's/(.*?)(,infinite|)$/\1,infinite/' $FILENAME + + pid=$(ps aux | grep dnsmasq | grep "$NETWORK_NAME" | grep -v root | awk '{print $2}') + sudo kill -s SIGHUP $pid + echo "Added infinite leases to $FILENAME" + fi + sleep 10 +done