Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Refactor app rollback checks and stop conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Heavybullets8 committed Dec 26, 2023
1 parent 0f24526 commit c74fd51
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions functions/update/post_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ failed_rollback() {
}

check_rollback_availability() {
if printf '%s\0' "${apps_with_status[@]}" | grep -iFxqz "${app_name},operator"; then
if [[ $operator == true ]]; then
echo_array+=("Error: $app_name contains an operator instance, and cannot be rolled back")
return 1
fi
if printf '%s\0' "${apps_with_status[@]}" | grep -iFxqz "${app_name},cnpg"; then
if [[ $cnpg == true ]]; then
echo_array+=("Error: $app_name contains a CNPG deployment, and cannot be rolled back")
echo_array+=("If this happens frequently, set a larger timeout, or set concurrency lower")
echo_array+=("If needed, you should have a backup of the database to restore from")
Expand Down
10 changes: 8 additions & 2 deletions functions/update/pre_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ should_start_app() {
return 0
fi

if printf '%s\0' "${apps_with_status[@]}" | grep -iFxqz "${app_name},stopAll-on" && [[ $startstatus == "ACTIVE" ]]; then
if [[ $stopAll == true && $startstatus == "ACTIVE" ]]; then
return 0
fi

Expand Down Expand Up @@ -92,6 +92,12 @@ pre_process() {
old_full_ver="${app_vars[2]}"
new_full_ver="${app_vars[3]}"
rollback_version="${app_vars[4]}"

export operator isStopped stopAll cnpg
operator=$(printf '%s\0' "${apps_with_status[@]}" | grep -iFxqz "${app_name},operator" && echo true || echo false)
isStopped=$(printf '%s\0' "${apps_with_status[@]}" | grep -iFxqz "${app_name},isStopped-on" && echo true || echo false)
stopAll=$(printf '%s\0' "${apps_with_status[@]}" | grep -iFxqz "${app_name},stopAll-on" && echo true || echo false)
cnpg=$(printf '%s\0' "${apps_with_status[@]}" | grep -iFxqz "${app_name},cnpg" && echo true || echo false)

echo_array+=("\n$app_name")

Expand All @@ -102,7 +108,7 @@ pre_process() {
fi
fi

if [[ $stop_before_update == true && "$startstatus" != "STOPPED" ]]; then
if [[ $operator == false && $stop_before_update == true && "$startstatus" != "STOPPED" ]]; then
if ! update_stop_handler 'Stopping prior to update..'; then
echo_array
return
Expand Down
4 changes: 3 additions & 1 deletion utils/check_filtered_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ check_filtered_apps() {
local app_name=$1

midclt call chart.release.get_instance "$app_name" | jq -r '
if .config.operator.enabled == true then
if .chart_metadata.name == "prometheus" then
.name + ",operator"
elif .catalog_train == "operators" then
.name + ",operator"
else
empty
Expand Down
4 changes: 2 additions & 2 deletions utils/stop_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ handle_stop_code() {
return 1
;;
3)
echo "HeavyScript doesn't have the ability to stop Prometheus"
echo "Operators are not meant to be stopped"
return 1
;;
esac
Expand All @@ -42,7 +42,7 @@ handle_stop_code() {
stop_app() {
# Return 1 if cli command outright fails
# Return 2 if timeout is reached
# Return 3 if app is a prometheus instance
# Return 3 if app is an operator

local stop_type app_name timeout status
stop_type="$1"
Expand Down

0 comments on commit c74fd51

Please sign in to comment.