diff --git a/utils/resources.sh b/utils/resources.sh index f2d836fd..0fec1761 100644 --- a/utils/resources.sh +++ b/utils/resources.sh @@ -5,7 +5,7 @@ pull_replicas() { app_name="$1" # First Check - replica_info=$(midclt call chart.release.get_instance "$app_name" | jq '.config.controller.replicas // .config.workload.main.replicas') + replica_info=$(midclt call chart.release.get_instance "$app_name" | jq '.config.workload.main.replicas // .config.controller.replicas') # Second Check if First Check returns null or 0 if [[ "$replica_info" == "null" || "$replica_info" == "0" ]]; then diff --git a/utils/start_app.sh b/utils/start_app.sh index 9feb3207..bef767bf 100644 --- a/utils/start_app.sh +++ b/utils/start_app.sh @@ -18,28 +18,33 @@ start_app(){ # Check if app is a cnpg instance, or an operator instance output=$(check_filtered_apps "$app_name") - # Remove this first if statement after a while - # it is only here to deal with previous errors for a while - if [[ $output == *"${app_name},official"* ]]; then - replicas=$(pull_replicas "$app_name") - if ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": '"$replicas}" > /dev/null 2>&1; then + + replicas=$(pull_replicas "$app_name") + if [[ -z "$replicas" || "$replicas" == "null" ]]; then + return 1 + fi + + if [[ $output == *"${app_name},stopAll-"* ]]; then + ix_apps_pool=$(get_apps_pool) + if [[ -z "$ix_apps_pool" ]]; then return 1 fi - elif [[ $output == *"${app_name},stopAll-"* ]]; then - ix_apps_pool=$(get_apps_pool) latest_version=$(midclt call chart.release.get_instance "$app_name" | jq -r ".chart_metadata.version") + if [[ -z "$latest_version" ]]; then + return 1 + fi if ! helm upgrade -n "ix-$app_name" "$app_name" \ "/mnt/$ix_apps_pool/ix-applications/releases/$app_name/charts/$latest_version" \ --kubeconfig "/etc/rancher/k3s/k3s.yaml" \ --reuse-values \ + --set replicaCount="$replicas" \ --set global.stopAll=false > /dev/null 2>&1; then return 1 fi else - replicas=$(pull_replicas "$app_name") if ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": '"$replicas}" > /dev/null 2>&1; then return 1 fi diff --git a/utils/stop_app.sh b/utils/stop_app.sh index 90faf109..198c6982 100644 --- a/utils/stop_app.sh +++ b/utils/stop_app.sh @@ -72,11 +72,6 @@ stop_app() { # Check if the output contains the desired namespace and "cnpg" or "operator" if echo "$output" | grep -q "${app_name},operator"; then return 3 - # Remove in the future. - # This is here for my mistake on handling non-truecharts apps - elif echo "$output" | grep -q "${app_name},official"; then - timeout "${timeout}s" cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": '"0}" > /dev/null 2>&1 - handle_timeout $? elif echo "$output" | grep -q "${app_name},stopAll-*"; then timeout "${timeout}s" cli -c "app chart_release update chart_release=\"$app_name\" values={\"global\": {\"stopAll\": true}}" > /dev/null 2>&1 handle_timeout $?