From 6b5427ed8b12c2da39a82161182fc887cb200511 Mon Sep 17 00:00:00 2001 From: saypaul Date: Tue, 28 Jan 2025 18:31:49 +0530 Subject: [PATCH] fix:fail early for any required script failure When greenboot encounters an error in required scripts,it braks out of the healthcheck loop and moves to redscript excution skipping the other required and wanted scripts.Logs are added to notify users of the skipped required scripts due to critical failure. Signed-off-by: saypaul --- usr/libexec/greenboot/greenboot | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/usr/libexec/greenboot/greenboot b/usr/libexec/greenboot/greenboot index e8dcbdb..348af6e 100755 --- a/usr/libexec/greenboot/greenboot +++ b/usr/libexec/greenboot/greenboot @@ -53,7 +53,9 @@ script_runner () { local required_hc_failed=false echo "$start_msg" for script in $(find "$scripts_dir" -name '*.sh' | sort); do - if is_disabled "$(basename "$script")"; then + if [[ "$required_hc_failed" == true && "$mode" == "strict" ]]; then + echo "<5>'$(basename "$script")' was skipped due to a previous failure" + elif is_disabled "$(basename "$script")"; then echo "'$(basename "$script")' was skipped, as specified in config" else local rc=0 @@ -82,7 +84,10 @@ case "$1" in "check") rc=0 for health_check_path in "${SCRIPTS_CHECK_PATHS[@]}"; do - script_runner "$health_check_path/required.d" "strict" "Running Required Health Check Scripts..." || rc=1 + script_runner "$health_check_path/required.d" "strict" "Running Required Health Check Scripts..." || { + rc=1 + break + } script_runner "$health_check_path/wanted.d" "relaxed" "Running Wanted Health Check Scripts..." done print_unexecuted_checks