Remove upgrade flags during abort

If the upgrade flags are present during controller-1 downgrade, the
controller will fail to unlock. Previously these were removed as part of
the host-downgrade command, but this requires root access. These flags
will now be removed by the conductor as part of the upgrade-abort
command.

Story: 2008055
Task: 41633
Signed-off-by: David Sullivan <david.sullivan@windriver.com>
Change-Id: I7bb60e42d956140e06e44145ab8b168d1f3b72be
This commit is contained in:
David Sullivan 2021-01-20 11:31:22 -06:00
parent e0d17af9c5
commit 52677deb2c
2 changed files with 21 additions and 18 deletions

View File

@ -2761,24 +2761,6 @@ class HostController(rest.RestController):
"host-downgrade rejected: Upgrade not in %s state." %
constants.UPGRADE_ABORTING))
if rpc_ihost.hostname == constants.CONTROLLER_1_HOSTNAME:
# Clear upgrade flags so controller-1 will not upgrade
# after install. This flag is guaranteed to be written on
# controller-0, since controller-1 must be locked to run
# the host-downgrade command.
try:
os.remove(tsc.CONTROLLER_UPGRADE_FLAG)
except OSError:
LOG.exception("Failed to remove upgrade flag")
try:
os.remove(tsc.CONTROLLER_UPGRADE_COMPLETE_FLAG)
except OSError:
LOG.exception("Failed to remove upgrade complete flag")
try:
os.remove(tsc.CONTROLLER_UPGRADE_FAIL_FLAG)
except OSError:
LOG.exception("Failed to remove upgrade fail flag")
# Check for new hardware since upgrade-start
force = body.get('force', False) is True
self._semantic_check_downgrade_refresh(upgrade, rpc_ihost, force)

View File

@ -9725,6 +9725,27 @@ class ConductorManager(service.PeriodicService):
self._puppet.update_system_config()
self._puppet.update_secure_system_config()
# There are upgrade flags that are written to controller-0 that need to
# be removed before downgrading controller-1. As these flags reside on
# controller-0, we restrict this to abort actions started on that
# controller. When the abort is run on controller-1 the data-migration
# must be complete, and only the CONTROLLER_UPGRADE_COMPLETE_FLAG would
# remain. The CONTROLLER_UPGRADE_COMPLETE_FLAG does not interfere with
# the host-downgrade. Any remaining flags will be removed during
# upgrade-complete.
if utils.is_host_active_controller(controller_0):
upgrade_flag_files = [
tsc.CONTROLLER_UPGRADE_FLAG,
tsc.CONTROLLER_UPGRADE_COMPLETE_FLAG,
tsc.CONTROLLER_UPGRADE_FAIL_FLAG,
tsc.CONTROLLER_UPGRADE_STARTED_FLAG
]
for file in upgrade_flag_files:
try:
os.remove(file)
except OSError:
LOG.exception("Failed to remove upgrade flag: %s" % file)
# When we abort from controller-1 while controller-0 is running
# the previous release, controller-0 will not be aware of the abort.
# We set the following flag so controller-0 will know we're