From 6535821e0879729c7900801e6f6d90042859cc9b Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Wed, 10 Feb 2021 15:22:17 -0600 Subject: [PATCH 1/2] Support lease expiry option This was added to metal3-dev-env in [0]. Expose the setting for dev-scripts too. 0: https://github.com/metal3-io/metal3-dev-env/pull/599 --- common.sh | 2 ++ config_example.sh | 3 +++ utils.sh | 8 +++++++- vm_setup_vars.yml | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common.sh b/common.sh index 9de3fc369..2bfab4516 100644 --- a/common.sh +++ b/common.sh @@ -214,6 +214,8 @@ MANAGE_INT_BRIDGE=${MANAGE_INT_BRIDGE:-y} INT_IF=${INT_IF:-} #Root disk to deploy coreOS - use /dev/sda on BM ROOT_DISK_NAME=${ROOT_DISK_NAME-"/dev/sda"} +# Length of DHCP leases +export DHCP_LEASE_EXPIRY=${DHCP_LEASE_EXPIRY:-60} FILESYSTEM=${FILESYSTEM:="/"} diff --git a/config_example.sh b/config_example.sh index b51142559..ca1e8da35 100755 --- a/config_example.sh +++ b/config_example.sh @@ -248,6 +248,9 @@ set -x #export METALLB_IMAGE_BASE= #export METALLB_IMAGE_TAG= +# Set the DHCP lease time +#export DHCP_LEASE_EXPIRY=60 + ## ## Multi-cluster/Hive variables ## diff --git a/utils.sh b/utils.sh index a11960609..1412af6e1 100755 --- a/utils.sh +++ b/utils.sh @@ -548,12 +548,18 @@ function bootstrap_ip { pref_ip=ipv4 fi - sudo virsh net-dhcp-leases ${BAREMETAL_NETWORK_NAME} \ + # TODO(bnemec): Remove this logic once we have libvirt 7.0 or higher. + # Older versions fail on infinite leases. + if [ "$DHCP_LEASE_EXPIRY" -ne "0" ]; then + sudo virsh net-dhcp-leases ${BAREMETAL_NETWORK_NAME} \ | grep -v master \ | grep "${pref_ip}" \ | tail -n1 \ | awk '{print $5}' \ | sed -e 's/\(.*\)\/.*/\1/' + else + echo "Unable to retrieve bootstrap IP with infinite leases enabled." 1>&2 + fi } function image_for() { diff --git a/vm_setup_vars.yml b/vm_setup_vars.yml index 35bebef5a..e58e3b17c 100644 --- a/vm_setup_vars.yml +++ b/vm_setup_vars.yml @@ -65,6 +65,7 @@ external_network: dhcp_range_v6: - "{{ baremetal_network_cidr_v6|nthhost(20) }}" - "{{ baremetal_network_cidr_v6|nthhost(60) }}" + lease_expiry: "{{ lookup('env', 'DHCP_LEASE_EXPIRY') }}" nat_port_range: - 1024 - 65535 From 22ab4daa12b859ea00099b249b85dc1a4927b80a Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Tue, 13 Apr 2021 16:52:20 -0500 Subject: [PATCH 2/2] Bump to current metal3-dev-env --- 01_install_requirements.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/01_install_requirements.sh b/01_install_requirements.sh index f0fb98f3e..11c3ef670 100755 --- a/01_install_requirements.sh +++ b/01_install_requirements.sh @@ -19,7 +19,7 @@ if [ -z "${METAL3_DEV_ENV}" ]; then # TODO -- come up with a plan for continuously updating this # Note we only do this in the case where METAL3_DEV_ENV is # unset, to enable developer testing of local checkouts - git reset 8908da5241d52e25a7e1b2e60d6d604cf797f890 --hard + git reset 184d0afaab77424872f0441c9e11e23a620e5b57 --hard popd fi @@ -43,7 +43,7 @@ sudo alternatives --set python /usr/bin/python3 pushd ${METAL3_DEV_ENV_PATH} ansible-galaxy install -r vm-setup/requirements.yml -ansible-galaxy collection install ansible.netcommon ansible.posix +ansible-galaxy collection install ansible.netcommon ansible.posix community.general ANSIBLE_FORCE_COLOR=true ansible-playbook \ -e "working_dir=$WORKING_DIR" \ -e "virthost=$HOSTNAME" \