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

Commit

Permalink
Update Lifecylce (#143)
Browse files Browse the repository at this point in the history
[Bugfix]
- Set replicas when scaling with helm
- Remove outdated code for official application lifecylce
- Add additional checks in start_app function
  • Loading branch information
Heavybullets8 authored Dec 23, 2023
1 parent 0079850 commit 7da4af9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion utils/resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 13 additions & 8 deletions utils/start_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions utils/stop_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $?
Expand Down

0 comments on commit 7da4af9

Please sign in to comment.