From 2ffc0c507391fe5a20a18b753b8cfa465a9599f9 Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Tue, 5 Nov 2019 10:46:43 +0100 Subject: [PATCH] Increase DHCP lease time to infinite (#3662) * Increase lease time to infinite Lease time set to effectively infinite (36000+ days) since we fully control VM lifecycle via CloudStack Infinite time helps avoid some edge cases which could cause DHCPNAK being sent to VMs since (RHEL) system lose routes when they receive DHCPNAK When VM is expunged, it's active lease and DHCP/DNS config is properly removed from related files in VR. * desc fix --- systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index 56b44195f6d..72c5daec0cc 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -160,9 +160,15 @@ class CsDhcp(CsDataBag): def add(self, entry): self.add_host(entry['ipv4_address'], entry['host_name']) - # lease time boils down to once a month - # with a splay of 60 hours to prevent storms - lease = randint(700, 760) + # Lease time set to effectively infinite (36000+ days) since we properly control all DHCP/DNS config via CloudStack. + # Infinite time helps avoid some edge cases which could cause DHCPNAK being sent to VMs since + # (RHEL) system lose routes when they receive DHCPNAK. + # When VM is expunged, its active lease and DHCP/DNS config is properly removed from related files in VR, + # so the infinite duration of lease does not cause any issues or garbage. + # There will be soon a PR which also regenerates the /var/lib/misc/dnsmasq.leases (active lease DB file) + # in the new VR (when restarting network with cleanup), which will help around RHEL edge cases (described above) + # for the VMs who are already running in productions systems with 30d lease time. + lease = randint(870000, 870010) if entry['default_entry']: self.cloud.add("%s,%s,%s,%sh" % (entry['mac_address'],