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

This commit is contained in:
Zuul 2024-04-17 13:18:10 +00:00 committed by Gerrit Code Review
commit 4c510b0cad
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.
@ -6736,6 +6745,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():