Merge "Move deployment flag cleanup to software agent"
This commit is contained in:
@@ -18,6 +18,7 @@ import time
|
||||
import software.agent_hooks as agent_hooks
|
||||
import software.ostree_utils as ostree_utils
|
||||
from software.software_functions import configure_logging
|
||||
from software.software_functions import remove_major_release_deployment_flags
|
||||
from software.software_functions import LOG
|
||||
import software.config as cfg
|
||||
from software.base import PatchService
|
||||
@@ -360,6 +361,8 @@ class SoftwareMessageDeployDeleteCleanupReq(messages.PatchMessage):
|
||||
nodetype = utils.get_platform_conf("nodetype")
|
||||
success_update = ostree_utils.add_ostree_remote(self.major_release, nodetype,
|
||||
replace_default_remote=True)
|
||||
success_flags = remove_major_release_deployment_flags()
|
||||
|
||||
if success_cleanup:
|
||||
LOG.info("Success cleaning temporary refs/remotes.")
|
||||
else:
|
||||
@@ -372,6 +375,12 @@ class SoftwareMessageDeployDeleteCleanupReq(messages.PatchMessage):
|
||||
LOG.error("Failure updating default remote. "
|
||||
"Please update '%s' remote manually." % constants.OSTREE_REMOTE)
|
||||
|
||||
if success_flags:
|
||||
LOG.info("Success removing local major release deployment flags.")
|
||||
else:
|
||||
LOG.error("Failure removing major release deployment flags. "
|
||||
"Please remove them manually.")
|
||||
|
||||
success = success_cleanup and success_update
|
||||
resp = SoftwareMessageDeployDeleteCleanupResp()
|
||||
resp.success = success
|
||||
|
||||
@@ -1477,16 +1477,26 @@ def clean_up_deployment_data(major_release):
|
||||
for folder in upgrade_folders:
|
||||
shutil.rmtree(folder, ignore_errors=True)
|
||||
|
||||
|
||||
def remove_major_release_deployment_flags():
|
||||
"""
|
||||
Cleanup local major release deployment flags
|
||||
"""
|
||||
upgrade_flags = [
|
||||
constants.USM_UPGRADE_IN_PROGRESS_FLAG,
|
||||
constants.UPGRADE_DO_NOT_USE_FQDN_FLAG,
|
||||
]
|
||||
success = True
|
||||
for flag in upgrade_flags:
|
||||
try:
|
||||
os.remove(flag)
|
||||
LOG.info("Flag %s removed." % flag)
|
||||
except FileNotFoundError:
|
||||
LOG.warning("Flag %s not found. Skipping..." % flag)
|
||||
except Exception as e:
|
||||
success = False
|
||||
LOG.exception("Failed to remove flag %s: %s" % (flag, str(e)))
|
||||
return success
|
||||
|
||||
|
||||
def run_deploy_clean_up_script(release):
|
||||
|
||||
Reference in New Issue
Block a user