From 829b8c5f758ce9979cdf193bb0cb0d64b31a7f9f Mon Sep 17 00:00:00 2001 From: Julien Fontaine Date: Thu, 25 Jun 2020 17:10:02 -0400 Subject: [PATCH] Explicit error message in command-executor when script is failing Changed error message to print the last execution log (if possible) when the executed script fails. Issue-ID: CCSDK-2481 Signed-off-by: Julien Fontaine Change-Id: I9df9dfeeaf95d98049c4f80f827deb85a29137da --- ms/command-executor/src/main/python/command_executor_handler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ms/command-executor/src/main/python/command_executor_handler.py b/ms/command-executor/src/main/python/command_executor_handler.py index 0c476b23e..7c9ef84c1 100644 --- a/ms/command-executor/src/main/python/command_executor_handler.py +++ b/ms/command-executor/src/main/python/command_executor_handler.py @@ -151,7 +151,12 @@ class CommandExecutorHandler(): if rc == 0: return utils.build_ret_data(True, results=result, results_log=results_log) else: - err_msg = "{} - Something wrong happened during command execution. See execute command logs for more information.".format(self.blueprint_id) + err_msg = "" + if len(results_log) > 0: + # get exception message + err_msg = "{} - {}".format(self.blueprint_id, results_log[-1:][0]) + else: + err_msg = "{} - Process exited with return code {}".format(self.blueprint_id, rc) return utils.build_ret_data(False, results=result, results_log=results_log, error=err_msg) def install_packages(self, request, type, f, results): -- 2.16.6