Send the correct mgmt-IP to mtce

After the management reconfiguration, it was not possible to apply a reboot-required
patch because the sysinv was sending the old mgmt IP adress to the mtce.
Consequently, mtce wasn't creating the required file (/var/run/.node_locked) during
the host-lock command.
This file is essential for the sw-patch tool to proceed with the installation.

Additionally, the management network reconfiguration runtime manifest can be executed
prematurely if the MGMT_NETWORK_RECONFIGURATION_ONGOING flag is used.
However, users might introduce other changes that could unintentionally trigger the
runtime manifests before the host-unlock command.
This could lead to unexpected keystone changes, potentially causing CLI blockage or
system reboots.

The MGMT_NETWORK_RECONFIGURATION_ONGOING flag is created when initiating management
network reconfiguration commands and it is intended to avoid update on the dnsmasq
files until system reboot.
Changed to MGMT_NETWORK_RECONFIGURATION_UNLOCK because this flag is intended to
guarantee keystone changes only occur during the unlock command.

Tests dome:
IPv4 AIO-SX fresh install
IPv4 AIO-DX with mgmt in vlan fresh install
IPv4 DC with subcloud AIO-SX
IPv4 AIO-SX mgmt reconfig and apply a reboot-required patch
IPv4 subcloud AIO-SX mgmt reconfig and apply a reboot-required patch

Partial-Bug: #2060066
Story: 2010722
Task: 49810

Change-Id: I138d8e31edd60a41a4595cfb8bd2dc478bc01013
This commit is contained in:
Fabiano Correa Mercer 2024-03-28 11:50:36 -03:00
parent ecdb0d3b9f
commit 4919bf7213
3 changed files with 21 additions and 12 deletions

View File

@ -2081,7 +2081,7 @@ class AgentManager(service.PeriodicService):
# Set ready flag for maintenance to proceed with the unlock of
# the initial controller.
utils.touch(constants.UNLOCK_READY_FLAG)
elif (os.path.isfile(tsc.MGMT_NETWORK_RECONFIGURATION_ONGOING) and
elif (os.path.isfile(tsc.MGMT_NETWORK_RECONFIGURATION_UNLOCK) and
applied_classes == ['openstack::keystone::endpoint::reconfig']):
# Set ready flag for maintenance to proceed with the unlock
# after mgmt ip reconfiguration

View File

@ -2047,6 +2047,19 @@ class HostController(rest.RestController):
"name={}, value={}. ").format(
capability, new_value))
def _get_mgmt_ip(self, hostname):
# Notify maintenance about updated mgmt_ip
# During mgmt network reconfiguration, do not change the mgmt IP
# in maintencance as it will be updated after the unlock.
if os.path.isfile(tsc.MGMT_NETWORK_RECONFIGURATION_ONGOING):
return cutils.gethostbyname(constants.CONTROLLER_0_FQDN)
else:
address_name = cutils.format_address_name(hostname,
constants.NETWORK_TYPE_MGMT)
address = utils.get_primary_address_by_name(address_name,
constants.NETWORK_TYPE_MGMT, True)
return address.address
def _patch(self, uuid, patch):
log_start = cutils.timestamped("ihost_patch_start")
@ -2299,16 +2312,7 @@ class HostController(rest.RestController):
ihost_obj['uuid'], {'capabilities': ihost_obj['capabilities']})
# Notify maintenance about updated mgmt_ip
# During mgmt network reconfiguration, do not change the mgmt IP
# in maintencance as it will be updated after the unlock.
if os.path.isfile(tsc.MGMT_NETWORK_RECONFIGURATION_ONGOING):
ihost_obj['mgmt_ip'] = cutils.gethostbyname(constants.CONTROLLER_0_FQDN)
else:
address_name = cutils.format_address_name(ihost_obj.hostname,
constants.NETWORK_TYPE_MGMT)
address = utils.get_primary_address_by_name(address_name,
constants.NETWORK_TYPE_MGMT, True)
ihost_obj['mgmt_ip'] = address.address
ihost_obj['mgmt_ip'] = self._get_mgmt_ip(ihost_obj.hostname)
hostupdate.notify_mtce = True
@ -2340,6 +2344,10 @@ class HostController(rest.RestController):
if nonmtc_change_count > 0:
LOG.info("%s Action %s perform notify_mtce" %
(hostupdate.displayid, myaction))
# Notify maintenance about updated mgmt_ip
ihost_obj['mgmt_ip'] = self._get_mgmt_ip(ihost_obj.hostname)
new_ihost_mtc = ihost_obj.as_dict()
new_ihost_mtc = cutils.removekeys_nonmtce(new_ihost_mtc)

View File

@ -2497,7 +2497,8 @@ class ConductorManager(service.PeriodicService):
if utils.config_is_reboot_required(host.config_target):
config_uuid = self._config_set_reboot_required(config_uuid)
self._puppet.update_host_config(host, config_uuid)
elif os.path.isfile(tsc.MGMT_NETWORK_RECONFIGURATION_ONGOING):
elif os.path.isfile(tsc.MGMT_NETWORK_RECONFIGURATION_UNLOCK):
# Remove unlock ready flag to prevent maintenance rebooting the
# node until the runtime manifest is finished.
try: