Update dnsmasq.hosts on every dhcp lease event and process startup

A call to _generate_dnsmasq_hosts_file is added to sysinv
conductor handle_dhcp_lease.

There are currently a number of calls to _generate_dnsmasq_hosts_file
as shown in this list.

  _create_or_update_address
  _allocate_addresses_for_host
  _unallocate_addresses_for_host
  _remove_addresses_for_host
   mgmt_ip_set_by_ihost
   reserve_ip_for_third_monitor_node
   reserve_ip_for_cinder
  _init_controller_for_upgrade

Most of these are for specific system configuration changes.
However, the introduction of the pxeboot network repurposed
the use and content of the dnsmasq.hosts file.

Given that the dnsmasq hosts file no longer maintains management
network addresses and hostname associations, the question of whether
the call to _generate_dnsmasq_hosts_file is needed for them at all
anymore. That could be discussed or commented on in this review.

Testing system responsiveness to dhcp lease changes revealed
that the dnsmasq.hosts file would only get updated when one of
the aforementioned procedures are called. In many cases it took
a long time after the leases file was updated before the change
was realized by the system through a dnamasq.hosts update.

Adding this call to every dhcp lease update makes sense in that
it makes the responsiveness of dhcp lease changes immediate.

Also, there is the possibility that a lease event is missed if it
occurs while the conductor is not running. This may occur over a
swact, patch or simply process restart by puppet.

This update addrersses this gap by adding a one time call to
_generate_dnsmasq_hosts_file in the _controller_config_active_apply
audit so that the dnsmasq hosts and addn_hosts files get update
over a conductor process restart.

Test Plan:

PASS: Build, test and install AIO DX Plus system.
PASS: Verify the dnsmasq.hosts and dnsmasq.addn_hosts files get
      updated immediately following a dnsmasq dhcp lease event
      and conductor process restart.
PASS: Verify the dnsmasq.hosts and dnsmasq.addn_hosts files get
      update over a swact.

Story: 2010940
Task: 49788
Change-Id: I8d55b865f682bd5e0e210481a9dff318baab436b
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2024-03-28 16:05:33 +00:00
parent de9d380dc9
commit 2a2733e7b3
1 changed files with 14 additions and 0 deletions

View File

@ -378,6 +378,14 @@ class ConductorManager(service.PeriodicService):
# Guard for a function that should run only once per conductor start
self._do_detect_swact = True
# Guard for a function that should run only once per conductor start
# A call to _generate_dnsmasq_hosts_file is added to the
# _controller_config_active_apply audit to ensure that
# it is run on conductor process startup. This variable
# is set True once called to avoid it being called on
# subsequent audits.
self._generate_dnsmasq_hosts_file_called = False
# Guard for a function that should run only once per conductor start
self._has_loaded_missing_apps_metadata = False
@ -1102,6 +1110,7 @@ class ConductorManager(service.PeriodicService):
# Create the ihost (if necessary).
ihost_dict = {'mgmt_mac': mac}
self.create_ihost(context, ihost_dict, reason='dhcp pxeboot')
self._generate_dnsmasq_hosts_file()
def handle_dhcp_lease_from_clone(self, context, mac):
"""Handle dhcp request from a cloned controller-1.
@ -6732,6 +6741,11 @@ class ConductorManager(service.PeriodicService):
"""Check whether target config has been applied to active
controller to run postprocessing"""
if not self._generate_dnsmasq_hosts_file_called:
# Refresh the dnsmasq.hosts file on process restart
self._generate_dnsmasq_hosts_file()
self._generate_dnsmasq_hosts_file_called = True
# check whether target config may be finished based upon whether
# the active controller has the active config target
if not self._controller_config_active_check():