Upgrade activation interrupted by host-swact

During an upgrade-activate the upgrade scripts can be interrupted by a
swact. We need to block the swact during the activation. If a swact does
occur we need to reset the upgrade state so the activate can be
attempted again.

Closes-Bug: 1917779
Change-Id: I9274319375296b2334533e386629d185e2b472ac
Signed-off-by: David Sullivan <david.sullivan@windriver.com>
This commit is contained in:
David Sullivan 2021-03-04 09:11:30 -06:00
parent d309c482c2
commit b9cd8ec6de
2 changed files with 20 additions and 0 deletions

View File

@ -5833,6 +5833,18 @@ class HostController(rest.RestController):
_("Swact action not allowed. Upgrade state must be %s") %
(constants.UPGRADE_DATA_MIGRATION_COMPLETE))
activating_states = [constants.UPGRADE_ACTIVATION_REQUESTED,
constants.UPGRADE_ACTIVATING]
if upgrade.state in activating_states and not force_swact:
# Block swacts during activation to prevent interrupting the
# upgrade scripts.
# Allow swacts during UPGRADE_ACTIVATING_HOSTS as the active
# controller may need a lock/unlock if a runtime manifest fails.
# Allow force swacts for recovery in edge cases.
raise wsme.exc.ClientSideError(
_("Swact action not allowed. Wait until the upgrade-activate "
"command completes"))
if upgrade.state in [constants.UPGRADE_ABORTING,
constants.UPGRADE_ABORTING_ROLLBACK]:
if to_host_load_id == upgrade.to_load:

View File

@ -402,6 +402,14 @@ class ConductorManager(service.PeriodicService):
if system_mode == constants.SYSTEM_MODE_SIMPLEX:
self._init_controller_for_upgrade(upgrade)
if upgrade.state in [constants.UPGRADE_ACTIVATION_REQUESTED,
constants.UPGRADE_ACTIVATING]:
# Reset to activation-failed if the conductor restarts. This could
# be due to a swact or the process restarting. Either way we'll
# need to rerun the activation.
self.dbapi.software_upgrade_update(
upgrade.uuid, {'state': constants.UPGRADE_ACTIVATION_FAILED})
self._upgrade_default_service()
self._upgrade_default_service_parameter()