From 0a6926c0d6567c6a9b05cdb023f4146e0bc0319a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 17:19:44 -0600 Subject: [PATCH] nested active check --- functions/update_apps.sh | 55 +++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 503e7afc..ec211d87 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -114,36 +114,45 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then do (( count++ )) status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then - if [[ $rollback == "true" ]]; then - if [[ "$failed" != "true" ]]; then - echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..") - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update - echo "$app_name,$new_full_ver" >> failed.txt - break - elif [[ "$failed" == "true" ]]; then - echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning") - break - fi - else - echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + if [[ "$status" == "ACTIVE" ]]; then + if [[ "$startstatus" == "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") break + else + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + echo_array+=("Active") + break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check echo_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo_array+=("Active") - break #if reports active any time after the first loop, assume actually active. + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + if [[ $rollback == "true" ]]; then + if [[ "$failed" != "true" ]]; then + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("If this is a slow starting application, set a higher timeout with -t") + echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") + echo_array+=("Reverting update..") + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + echo "$app_name,$new_full_ver" >> failed.txt + break + else + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("The application failed to be ACTIVE even after a rollback") + echo_array+=("Manual intervention is required\nAbandoning") + break + fi + else + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("If this is a slow starting application, set a higher timeout with -t") + echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") + break + fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15