From 541f646fb13f0911a959fd84ed0f6c8185a9ca22 Mon Sep 17 00:00:00 2001 From: Pablo Acevedo Montserrat Date: Tue, 30 May 2023 12:36:54 +0200 Subject: [PATCH] USHIFT-1286: Use exit code 1 in greenboot failures All MicroShift failures return 1 except for the service not being able to start. This happens because it shortcuts error checking by sending a SIGTERM to itself so that it exits immediately. The default handler for this signal returns exit code 143, whereas all the other known failure conditions return 1. When testing this behavior the greenboot script is not consistent when something fails. This change creates a specific handler for TERM so that the exit code is also 1. --- packaging/greenboot/microshift-running-check.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packaging/greenboot/microshift-running-check.sh b/packaging/greenboot/microshift-running-check.sh index 0bba48ffdb..3b5d00cc7d 100755 --- a/packaging/greenboot/microshift-running-check.sh +++ b/packaging/greenboot/microshift-running-check.sh @@ -10,9 +10,18 @@ PODS_CT_LIST=(2 1 1 2 # shellcheck source=packaging/greenboot/functions.sh source /usr/share/microshift/functions/greenboot.sh +# Set the term handler to convert exit code to 1 +trap 'return_failure' TERM + # Set the exit handler to log the exit status trap 'script_exit' EXIT +# The term handler to override the default behavior and have a uniform and +# homogeneous exit code in all controlled situations. +function return_failure() { + exit 1 +} + # The script exit handler logging the FAILURE or FINISHED message depending # on the exit status of the last command #