Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

greenboot: warn users of missing disabled healthchecks #141

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion usr/libexec/greenboot/greenboot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LC_ALL=C
SCRIPTS_CHECK_PATHS=("/usr/lib/greenboot/check" "/etc/greenboot/check")
SCRIPTS_GREEN_PATHS=("/usr/lib/greenboot/green.d" "/etc/greenboot/green.d")
SCRIPTS_RED_PATHS=("/usr/lib/greenboot/red.d" "/etc/greenboot/red.d")
declare -A DIS_CHECK_STATUS=()

source_configuration_file() {
greenboot_configuration_file=/etc/greenboot/greenboot.conf
Expand All @@ -15,15 +16,36 @@ source_configuration_file() {
fi
}

source_configuration_file
function init_disabled_map {
for disabled_healthcheck in "${DISABLED_HEALTHCHECKS[@]}"; do
DIS_CHECK_STATUS["$disabled_healthcheck"]=1;
done
}

source_configuration_file
function print_unexecuted_checks {
for disabled_healthcheck in "${DISABLED_HEALTHCHECKS[@]}"; do
if [[ "${DIS_CHECK_STATUS[$disabled_healthcheck]}" == 1 ]]; then
echo "WARNING: $disabled_healthcheck was not found and may be misspelled"
fi
done
}

source_configuration_file
function is_disabled {
healthcheck=$1
for disabled_healthcheck in "${DISABLED_HEALTHCHECKS[@]}"; do
if [ "${healthcheck}" == "${disabled_healthcheck}" ]; then return 0; fi
if [ "${healthcheck}" == "${disabled_healthcheck}" ]; then
DIS_CHECK_STATUS["${disabled_healthcheck}"]=0
return 0
fi
done
return 1
}

init_disabled_map

script_runner () {
local scripts_dir=$1; shift
local mode=$1; shift
Expand Down Expand Up @@ -63,6 +85,7 @@ case "$1" in
script_runner "$health_check_path/required.d" "strict" "Running Required Health Check Scripts..." || rc=1
script_runner "$health_check_path/wanted.d" "relaxed" "Running Wanted Health Check Scripts..."
done
print_unexecuted_checks
exit $rc
;;
"green")
Expand Down
Loading