From c30a58a4abfb5f03484b44188f5f9144e2d155a5 Mon Sep 17 00:00:00 2001 From: Heitor Matsui Date: Thu, 8 Aug 2024 18:38:57 -0300 Subject: [PATCH] Update mgmt-ip hieradata on controller-0 rollback This commit adds support to rolling back from stx-10 to stx-8 using USM, since the upgrade status are different between USM and legacy upgrade. The commit also fixes an incompatibility type issue while trying to create the hostname string. Test Plan PASS: AIO-DX - host-rollback and unlock controller-0 successfully Story: 2010676 Task: 50815 Change-Id: If07613fce99cd4bd4945a5a0b8c074bc3c74b404 Signed-off-by: Heitor Matsui --- sysinv/sysinv/sysinv/sysinv/common/constants.py | 2 ++ sysinv/sysinv/sysinv/sysinv/puppet/puppet.py | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sysinv/sysinv/sysinv/sysinv/common/constants.py b/sysinv/sysinv/sysinv/sysinv/common/constants.py index f6fb7489f2..0188046d68 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/constants.py +++ b/sysinv/sysinv/sysinv/sysinv/common/constants.py @@ -2646,6 +2646,8 @@ ISSUER = "Issuer" DEPLOY_STATE_HOST = 'host' # host is being deploy DEPLOY_STATE_HOST_FAILED = 'host-failed' # host deployment failed DEPLOY_STATE_COMPLETED = 'completed' +DEPLOY_STATE_HOST_ROLLBACK = 'host-rollback' +DEPLOY_STATE_HOST_ROLLBACK_DONE = 'host-rollback-done' # USM deploy host state DEPLOY_HOST_PENDING = 'pending' # host is pending for new deployment diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py b/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py index d4cc2ae342..593ba0df35 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py @@ -186,16 +186,16 @@ class PuppetOperator(object): def _is_controller0_downgrade(self, host, hiera_file): """ - check if controller-0 will execute a downgrade for a version - using mgmt_ip.yaml. - for AIO-SX it is not relevant + Check if controller-0 will execute a downgrade for a version + using mgmt_ip.yaml """ - if (tsc.system_mode != constants.SYSTEM_MODE_SIMPLEX and - host.hostname == constants.CONTROLLER_0_HOSTNAME and + if (host.hostname == constants.CONTROLLER_0_HOSTNAME and not os.path.exists(hiera_file)): try: upgrade = usm_service.get_platform_upgrade(self.dbapi) - if (upgrade.state == constants.UPGRADE_ABORTING_ROLLBACK): + if upgrade.state in [constants.UPGRADE_ABORTING_ROLLBACK, + constants.DEPLOY_STATE_HOST_ROLLBACK, + constants.DEPLOY_STATE_HOST_ROLLBACK_DONE]: LOG.info("controller-0 downgrade for a version using .yaml") return True except Exception: @@ -278,7 +278,7 @@ class PuppetOperator(object): if self._is_controller0_downgrade(host, hiera_file): mgmt_address = self._get_address_by_name( constants.CONTROLLER_0_HOSTNAME, constants.NETWORK_TYPE_MGMT) - filename = mgmt_address + ".yaml" + filename = "%s.yaml" % mgmt_address.address with io.open(os.path.join(path, filename), 'r', encoding='utf-8') as yaml_file: