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 a error in any of the requird scripts, it
breaks out the healtcheck loop and moves to red script execution. Logs
added to notify user of the scripts that are skipped due to critial
failure.

Signed-off-by: saypaul <[email protected]>
  • Loading branch information
say-paul committed Jan 28, 2025
1 parent 2751a7d commit a5d67cc
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 a5d67cc

Please sign in to comment.