Skip to content

Commit

Permalink
fix:fail early for any required script failure
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
say-paul committed Jan 28, 2025
1 parent 2751a7d commit 8500356
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions usr/libexec/greenboot/greenboot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8500356

Please sign in to comment.