From 94cc0843abc8ec004b4e66f969b48cbd075568d6 Mon Sep 17 00:00:00 2001 From: Lindley Vieira Date: Thu, 10 Oct 2024 14:43:59 -0300 Subject: [PATCH] Do not deploy if pre-install fails If pre-install script execution fails the software agent still tries to create the deploy and run the post-install script. This commit fixes it by returning and setting the state to deploy-host-failed. Test-plan SX and DX: PASS: deploy 24.09.1-preinstall-failure.patch, abort after the error and rollback. Story: 2010676 Task: 51160 Change-Id: If409ec3065172241170279023bb08b7e13366ffe Signed-off-by: Lindley Vieira --- software/software/software_agent.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/software/software/software_agent.py b/software/software/software_agent.py index 14f43e61..fae9d52c 100644 --- a/software/software/software_agent.py +++ b/software/software/software_agent.py @@ -689,6 +689,12 @@ class PatchAgent(PatchService): # "/sysroot/ostree/repo/config" file ostree_utils.pull_ostree_from_remote(remote=remote) setflag(ostree_pull_completed_deployment_pending_file) + + # Create a new deployment once the changes are pulled + ostree_utils.create_deployment(ref=ref) + + changed = True + clearflag(ostree_pull_completed_deployment_pending_file) except OSTreeCommandFail: LOG.exception("Failed to pull changes and create deployment" "during host-install.") @@ -698,18 +704,6 @@ class PatchAgent(PatchService): LOG.error("Command output: %s", e.output) success = False - try: - # Create a new deployment once the changes are pulled - ostree_utils.create_deployment(ref=ref) - - changed = True - clearflag(ostree_pull_completed_deployment_pending_file) - - except OSTreeCommandFail: - LOG.exception("Failed to pull changes and create deployment" - "during host-install.") - success = False - if changed: # Update the node_is_patched flag setflag(node_is_patched_file)