From e8d418c0917875d304cd68a0bff3f5efb49c16da Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Fri, 28 Feb 2020 09:57:09 +0100 Subject: [PATCH] router: Fix dhcp infinite lease time (#3913) The previous setup of many hours would not work, due to some internal dnsmasq issues - lease was set correclty, but dnsmasq was setting the dhcp-renew-time (and rebind time) to less than 2 years from the date the lease was issued. Using "infinite" as the value (instead of the number) works as expected - and (atm) the renew date is set to year 2088, etc. Co-authored-by: dahn --- systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index d0b40e52de5..75863726238 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -174,21 +174,18 @@ class CsDhcp(CsDataBag): def add(self, entry): self.add_host(entry['ipv4_address'], entry['host_name']) - # Lease time set to effectively infinite (36000+ days) since we properly control all DHCP/DNS config via CloudStack. + # Lease time set to "infinite" 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) + lease = 'infinite' if entry['default_entry']: - self.cloud.add("%s,%s,%s,%sh" % (entry['mac_address'], - entry['ipv4_address'], - entry['host_name'], - lease)) + self.cloud.add("%s,%s,%s,%s" % (entry['mac_address'], + entry['ipv4_address'], + entry['host_name'], + lease)) else: tag = entry['ipv4_address'].replace(".", "_") self.cloud.add("%s,set:%s,%s,%s,%sh" % (entry['mac_address'],