Create USM upgrade in progress flag

This commit creates a flag to indicate there is an USM
major release deployment (or upgrade) in progress to be
used by other parts of the system to do specific tasks
like provisioning and configuration that are relevant in
this scenario, and this commit also deletes the upgrade
flags in deploy delete.

Test Plan
PASS: (AIO-DX) full major release deployment

Story: 2010676
Task: 50701

Change-Id: Id277d985cdfd7ccf95a63d16910093d7c1fb5761
Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
This commit is contained in:
Heitor Matsui
2024-07-30 13:02:24 -03:00
parent fc4408ea48
commit af9c53d298
3 changed files with 25 additions and 2 deletions

View File

@@ -113,6 +113,16 @@ class ReconfigureKernelHook(BaseHook):
LOG.exception(msg)
class CreateUSMUpgradeInProgressFlag(BaseHook):
def __init__(self, attrs):
super().__init__(attrs)
def run(self):
flag_file = constants.USM_UPGRADE_IN_PROGRESS_FLAG
with open(flag_file, "w") as _:
LOG.info("Created %s flag" % flag_file)
# pre and post keywords
PRE = "pre"
POST = "post"
@@ -124,7 +134,7 @@ MAJOR_RELEASE_ROLLBACK = "major_release_rollback"
# agent hooks mapping per action
AGENT_HOOKS = {
MAJOR_RELEASE_UPGRADE: {
PRE: [],
PRE: [CreateUSMUpgradeInProgressFlag],
POST: [
CopyPxeFilesHook,
ReconfigureKernelHook,

View File

@@ -175,5 +175,7 @@ COMMIT_TAG = "commit"
CHECKSUM_TAG = "checksum"
COMMIT1_TAG = "commit1"
# install local flag
# flags
INSTALL_LOCAL_FLAG = "/opt/software/.install_local"
USM_UPGRADE_IN_PROGRESS_FLAG = os.path.join(tsc.PLATFORM_CONF_PATH, ".usm_upgrade_in_progress")
UPGRADE_DO_NOT_USE_FQDN_FLAG = os.path.join(tsc.PLATFORM_CONF_PATH, ".upgrade_do_not_use_fqdn")

View File

@@ -1476,6 +1476,17 @@ def clean_up_deployment_data(major_release):
for folder in upgrade_folders:
shutil.rmtree(folder, ignore_errors=True)
upgrade_flags = [
constants.USM_UPGRADE_IN_PROGRESS_FLAG,
constants.UPGRADE_DO_NOT_USE_FQDN_FLAG,
]
for flag in upgrade_flags:
try:
os.remove(flag)
LOG.info("Flag %s removed.")
except FileNotFoundError:
LOG.warning("Flag %s not found. Skipping...")
def run_deploy_clean_up_script(release):
"""