From 8c18514af39c0f20e2a9d1da376ceb32957581e6 Mon Sep 17 00:00:00 2001 From: Fabiano Mercer Date: Tue, 21 Mar 2023 13:04:25 -0300 Subject: [PATCH] Keep platform-nfs-ip for upgrade process The platform-nfs-ip service is not necessary for fresh installs because it is just an alias for the controller IP. But for old releases like StarlingX rel. 6 or 7 the platform-nfs-ip uses a specific IP, If for some reason an error occurs during the upgrade process, the upgrade will be aborted and the nodes will downgrade to the older release again. At this moment the nodes will try to communicate with the previous platform-nfs-ip IP configured in /etc/hosts. But if the active controller is using the new Release this IP doesn't exist anymore and the downgrade will fail. For this reason the platform-nfs-ip service will be available just for upgrade operations and will be deprovisioned for fresh installs or at the end of the upgrade process ( upgrade-activate phase ). Test plan PASS Fresh install on AIO-SX Fresh install on AIO-DX PASS Upgrade AIO-DX system from CENTOS Rel 7 to DEBIAN Rel 8 PASS Reboot controller-0 during upgrade of AIO-DX controller-1 was the active one with the new release ( Rel 8 ) controller-0 using old release. reboot controller-0 and check if it could connect to controller-1 using old platform-nfs-ip. PASS Upgrade-abort during AIO-DX upgrade controller-1 was the active controller and already upgraded controller-0 was upgraded but locked. Abort the upgrade and downgrade to old release ( Rel 7 ) Partial-Bug: #2012387 Depends-On: https://review.opendev.org/c/starlingx/stx-puppet/+/878122 Signed-off-by: Fabiano Mercer Change-Id: Ia7217544f2c954a83af71d488e0f2d722e17ec64 --- .../69-update-nfs-ip-address-alias.py | 13 +---- .../sysinv/sysinv/sysinv/conductor/manager.py | 47 +++++++++++++++++++ .../sysinv/sysinv/sysinv/puppet/networking.py | 17 +++++++ 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py b/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py index 125deb387a..bd6d1cd3f3 100644 --- a/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py +++ b/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py @@ -74,13 +74,6 @@ def _add_nfs_alias_to_hosts_file(connection, to_release): 'in {}'.format(ctrl_mgmt_ip['address'], host_file)) -def _remove_nfs_ip_allocation(connection): - with connection.cursor(cursor_factory=DictCursor) as cur: - LOG.info("Del controller-platform-nfs-mgmt from 'addresses' table") - cur.execute("DELETE FROM addresses WHERE " - "name = 'controller-platform-nfs-mgmt';") - - def main(): action = None from_release = None @@ -110,7 +103,6 @@ def main(): conn = psycopg2.connect("dbname=sysinv user=postgres") try: _add_nfs_alias_to_hosts_file(conn, to_release) - _remove_nfs_ip_allocation(conn) except psycopg2.Error as ex: LOG.exception(ex) @@ -121,10 +113,9 @@ def main(): LOG.warning("Exception") res = 1 else: - LOG.info("committing changes into database") - conn.commit() + LOG.info("controller-platform-nfs alias updated") finally: - LOG.info("Closing connection") + LOG.info("Closing DB connection") conn.close() return res diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py index 01f21debe9..8aa30343fd 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py @@ -7491,6 +7491,37 @@ class ConductorManager(service.PeriodicService): } self._config_apply_runtime_manifest(context, config_uuid, config_dict) + # TODO: update_platform_nfs_ip_references is just necessary to allow an upgrade + # from StarlingX releases 6 or 7 to new releases. + # remove it when StarlingX rel. 6 or 7 are not being used anymore + def update_platform_nfs_ip_references(self, context): + """Update platform nfs ip references during upgrade""" + + address_name = cutils.format_address_name('controller-platform-nfs', + constants.NETWORK_TYPE_MGMT) + + if not cutils.is_aio_simplex_system(self.dbapi): + personalities = [constants.CONTROLLER] + + config_uuid = self._config_update_hosts(context, personalities) + config_dict = { + "personalities": personalities, + "classes": ['platform::network::update_platform_nfs_ip_references'], + } + self._config_apply_runtime_manifest(context, config_uuid, config_dict) + + try: + # remove IP address from DB + address_uuid = self.dbapi.address_get_by_name(address_name).uuid + self.dbapi.address_destroy(address_uuid) + except exception.AddressNotFoundByName: + LOG.info("exception: AddressNotFoundByName: {}".format(address_name)) + except exception.AddressNotFound: + LOG.info("exception: AddressNotFound: {}".format(address_name)) + except Exception as e: + LOG.exception(e) + LOG.error("exception: address: {} could not be deleted".format(address_name)) + def update_clock_synchronization_config(self, context, host): """Update clock_synchronization configuration of a host""" personalities = [host.get('personality')] @@ -12419,6 +12450,22 @@ class ConductorManager(service.PeriodicService): upgrade.uuid, {'state': constants.UPGRADE_ACTIVATION_FAILED}) + # Remove platform-nfs-ip references if it exists + # TODO: platform-nfs-ip is just necessary to allow an upgrade from StarlingX + # releases 6 or 7 to new releases. + # remove the plat_nfs_address_name and update_platform_nfs_ip_references when + # StarlingX rel. 6 or 7 are not being used anymore + plat_nfs_address_name = cutils.format_address_name("controller-platform-nfs", + constants.NETWORK_TYPE_MGMT) + try: + self.dbapi.address_get_by_name(plat_nfs_address_name) + + LOG.info("platform-nfs-ip exists in the DB, updating all references") + self.update_platform_nfs_ip_references(context) + + except exception.AddressNotFoundByName: + LOG.debug("activate_upgrade: {} does not exist".format(plat_nfs_address_name)) + manifests_applied = False if manifests_applied: diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/networking.py b/sysinv/sysinv/sysinv/sysinv/puppet/networking.py index 519c31f105..7ebeb43e14 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/networking.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/networking.py @@ -60,6 +60,23 @@ class NetworkingPuppet(base.BasePuppet): gateway_address, }) + # TODO: platform-nfs-iaddress is just necessary to allow an upgrade + # from StarlingX releases 6 or 7 to new releases. + # remove it when StarlingX rel. 6 or 7 are not being used anymore + # During the upgrade If platform-nfs-ip is still available in the DB, + # add it to the config to allow downgrade if something goes wrong + try: + platform_nfs_address = self._get_address_by_name( + 'controller-platform-nfs', networktype).address + except exception.AddressNotFoundByName: + platform_nfs_address = None + + if platform_nfs_address is not None: + config.update({ + 'platform::network::%s::params::platform_nfs_address' % networktype: + platform_nfs_address, + }) + return config def _get_cluster_network_config(self):