From 4919bf72138e0a886637e58723aadff421e74adf Mon Sep 17 00:00:00 2001 From: Fabiano Correa Mercer Date: Thu, 28 Mar 2024 11:50:36 -0300 Subject: [PATCH] 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 --- sysinv/sysinv/sysinv/sysinv/agent/manager.py | 2 +- .../sysinv/sysinv/api/controllers/v1/host.py | 28 ++++++++++++------- .../sysinv/sysinv/sysinv/conductor/manager.py | 3 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/sysinv/sysinv/sysinv/sysinv/agent/manager.py b/sysinv/sysinv/sysinv/sysinv/agent/manager.py index 3a61621fd3..59f1e73fa1 100644 --- a/sysinv/sysinv/sysinv/sysinv/agent/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/agent/manager.py @@ -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 diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py index 84ede372e2..83efc1073e 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py @@ -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) diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py index 3d47d2f968..80480566e7 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py @@ -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: