From 555c541eebd5d7ff093212510cc6972f80325fc4 Mon Sep 17 00:00:00 2001 From: Bin Qian Date: Thu, 10 Feb 2022 10:17:45 -0500 Subject: [PATCH] Add api to query an upgrade is in progress Add api to query an upgrade is in progress. This is to support kickstarts to avoid processing installer RPMs in future releases. This change introduces a new sysinv API to query if an upgrade is in progress (i.e, upgrade starts, but not abort). TCs: Upgrade from 21.05 -> 21.12 abort after controller-1 upgrade completed Upgrade from 21.05 -> 21.12 Upgrade from 21.12 -> 22.02 abort after controller-1 upgrade completed Upgrade from 21.12 -> 22.02 load delete after 21.05 -> 21.12 upgrade abort load delete after 21.05 -> 21.12 upgrade complete load delete after 21.12 -> 22.02 upgrade abort load delete after 21.12 -> 22.02 upgrade complete Partial-bug: 1961424 Change-Id: Iaa49acca0dd365601fa2475c22aee2a4f668eb4d Signed-off-by: Bin Qian --- sysinv/sysinv/sysinv/sysinv/api/config.py | 1 + .../sysinv/api/controllers/v1/upgrade.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/sysinv/sysinv/sysinv/sysinv/api/config.py b/sysinv/sysinv/sysinv/sysinv/api/config.py index 8821b14f53..59364aaa00 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/config.py +++ b/sysinv/sysinv/sysinv/sysinv/api/config.py @@ -33,5 +33,6 @@ app = { '/v1/ihosts/[a-z0-9\-]+/icpus/platform_cpu_list', '/v1/ihosts/[a-z0-9\-]+/icpus/vswitch_cpu_list', '/v1/upgrade/[a-zA-Z0-9\-]+/in_upgrade', + '/v1/upgrade/[a-zA-Z0-9\-]+/upgrade_in_progress', ] } diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/upgrade.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/upgrade.py index b801416512..805c7eb641 100755 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/upgrade.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/upgrade.py @@ -124,6 +124,7 @@ class UpgradeController(rest.RestController): _custom_actions = { 'check_reinstall': ['GET'], 'in_upgrade': ['GET'], + 'upgrade_in_progress': ['GET'], } def __init__(self, parent=None, **kwargs): @@ -449,3 +450,20 @@ class UpgradeController(rest.RestController): except exception.NotFound: return False return True + + @wsme_pecan.wsexpose(wtypes.text, six.text_type) + def upgrade_in_progress(self, uuid): + # uuid is added here for potential future use + try: + upgrade = pecan.request.dbapi.software_upgrade_get_one() + + # upgrade in progress only when upgrade starts and not abort + if upgrade.state and upgrade.state not in [ + constants.UPGRADE_ABORTING_ROLLBACK, + constants.UPGRADE_ABORTING, + constants.UPGRADE_ABORT_COMPLETING]: + return True + + except exception.NotFound: + return False + return False