From 831d3d3e9350a43335744cabc7592f0adac7892f Mon Sep 17 00:00:00 2001 From: Lindley Werner Date: Mon, 4 Mar 2024 16:08:25 -0300 Subject: [PATCH] Fix deploy host for in-service patch 'software deploy host ' should NOT fail if there is no restart-script (post-deploy script). If the rsync does not find the scripts, does not raise an exception. Test-plan: PASS: software deploy host successful Closes-bug: 2058393 Change-Id: I1b8cac9e0401c3f64c7334139c62bf272e9aeb56 Signed-off-by: Lindley Werner --- software/software/software_agent.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/software/software/software_agent.py b/software/software/software_agent.py index 6909feae..bcac170a 100644 --- a/software/software/software_agent.py +++ b/software/software/software_agent.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2023 Wind River Systems, Inc. +Copyright (c) 2024 Wind River Systems, Inc. SPDX-License-Identifier: Apache-2.0 @@ -71,15 +71,24 @@ def clearflag(fname): def pull_restart_scripts_from_controller(): # If the rsync fails, it raises an exception to # the caller "handle_install()" and fails the - # host-install request for this host - output = subprocess.check_output(["rsync", - "-acv", - "--delete", - "--exclude", "tmp", - "rsync://controller/repo/software-scripts/", - "%s/" % insvc_software_scripts], - stderr=subprocess.STDOUT) - LOG.info("Synced restart scripts from controller: %s", output) + # host-install request for this host. + # The restart_scripts are optional, so if the files + # are not present, it should not raise any exception + try: + output = subprocess.check_output(["rsync", + "-acv", + "--delete", + "--exclude", "tmp", + "rsync://controller/repo/software-scripts/", + "%s/" % insvc_software_scripts], + stderr=subprocess.STDOUT) + LOG.info("Synced restart scripts from controller: %s", output) + except subprocess.CalledProcessError as e: + if "No such file or directory" in e.output.decode("utf-8"): + LOG.info("No restart scripts contained in the release") + else: + LOG.exception("Failed to sync restart scripts from controller") + raise def check_install_uuid():