Skip to content

Commit

Permalink
consistent clustername across scripts (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
adusumillipraveen authored Oct 31, 2023
1 parent f4afdfa commit 671378b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions scripts/aks/auto-shutdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jq -c '.[]' <<< $SUBSCRIPTIONS | while read subscription; do
subscription
jq -c '.[]' <<< $CLUSTERS | while read cluster; do
cluster
cluster_env=$(echo $cluster_name | cut -d'-' -f2)
cluster_env=$(echo $CLUSTER_NAME | cut -d'-' -f2)
cluster_env=${cluster_env/#sbox/Sandbox}
cluster_env=${cluster_env/stg/Staging}
cluster_business_area=$(echo $cluster_name | cut -d'-' -f1)
cluster_business_area=$(echo $CLUSTER_NAME | cut -d'-' -f1)
cluster_business_area=${cluster_business_area/ss/cross-cutting}
SKIP=$(should_skip_shutdown $cluster_env $cluster_business_area)

if [[ $SKIP == "false" ]]; then
echo -e "${GREEN}About to shutdown cluster $cluster_name (rg:$RESOURCE_GROUP)"
echo az aks stop --resource-group $RESOURCE_GROUP --name $cluster_name --no-wait || echo Ignoring any errors stopping cluster
az aks stop --resource-group $RESOURCE_GROUP --name $cluster_name --no-wait || echo Ignoring any errors stopping cluster
echo -e "${GREEN}About to shutdown cluster $CLUSTER_NAME (rg:$RESOURCE_GROUP)"
echo az aks stop --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --no-wait || echo Ignoring any errors stopping cluster
az aks stop --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --no-wait || echo Ignoring any errors stopping cluster
else
echo -e "${AMBER}cluster $cluster_name (rg:$RESOURCE_GROUP) has been skipped from today's shutdown schedule"
echo -e "${AMBER}cluster $CLUSTER_NAME (rg:$RESOURCE_GROUP) has been skipped from today's shutdown schedule"
fi
done
done
8 changes: 4 additions & 4 deletions scripts/aks/auto-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function process_clusters() {
subscription
jq -c '.[]' <<< $CLUSTERS | while read cluster; do
cluster
ts_echo "About to start cluster $NAME (rg:$RESOURCE_GROUP)"
az aks start --resource-group $RESOURCE_GROUP --name $NAME --no-wait || ts_echo Ignoring any errors starting cluster $NAME
ts_echo "About to start cluster $CLUSTER_NAME (rg:$RESOURCE_GROUP)"
az aks start --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --no-wait || ts_echo Ignoring any errors starting cluster $CLUSTER_NAME
done
done

Expand All @@ -22,8 +22,8 @@ function process_clusters() {
jq -c '.[]' <<< $CLUSTERS | while read cluster; do
cluster
check_cluster_status
POWER_STATE=$(az aks show --name $NAME -g $RESOURCE_GROUP | jq -r .powerState.code)
ts_echo "cluster: $NAME, Power State : ${RESULT}"
POWER_STATE=$(az aks show --name $CLUSTER_NAME -g $RESOURCE_GROUP | jq -r .powerState.code)
ts_echo "cluster: $CLUSTER_NAME, Power State : ${RESULT}"
done
done
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/aks/common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function subscription() {

function cluster() {
RESOURCE_GROUP=$(jq -r '.resourceGroup' <<< $cluster)
NAME=$(jq -r '.name' <<< $cluster)
CLUSTER_NAME=$(jq -r '.name' <<< $cluster)
}

function ts_echo() {
Expand Down Expand Up @@ -50,14 +50,14 @@ function check_cluster_status() {
fi
done

ts_echo "Test that $APP works in $ENVIRONMENT after $NAME start-up"
ts_echo "Test that $APP works in $ENVIRONMENT after $CLUSTER_NAME start-up"

statuscode=$(curl --max-time 30 --retry 20 --retry-delay 15 -s -o /dev/null -w "%{http_code}" https://$APPLICATION.platform.hmcts.net)

if [[ ("$ENVIRONMENT" == "demo" || $statuscode -eq 200) ]]; then
notification "#aks-monitor-$ENV" "$APP works in $ENVIRONMENT after $NAME start-up"
notification "#aks-monitor-$ENV" "$APP works in $ENVIRONMENT after $CLUSTER_NAME start-up"
else
message="$APP does not work in $ENVIRONMENT after $NAME start-up. Please check cluster."
message="$APP does not work in $ENVIRONMENT after $CLUSTER_NAME start-up. Please check cluster."
ts_echo "$message"
notification "#green-daily-checks" "$message"
notification "#aks-monitor-$ENV" "$message"
Expand Down
10 changes: 5 additions & 5 deletions scripts/aks/manual-start-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source scripts/aks/set-subscription.sh

function cluster() {
RESOURCE_GROUP=$(jq -r '.resourceGroup' <<<$cluster)
NAME=$(jq -r '.name' <<<$cluster)
CLUSTER_NAME=$(jq -r '.name' <<<$cluster)
}

MODE=${1:-start}
Expand All @@ -27,13 +27,13 @@ for INSTANCE in ${INSTANCES[@]}; do
jq -c '.[]' <<<$CLUSTERS | while read cluster; do
cluster

ts_echo "About to $MODE cluster $NAME (rg:$RESOURCE_GROUP)"
az aks $MODE --resource-group $RESOURCE_GROUP --name $NAME --no-wait || ts_echo Ignoring any errors while doing $MODE operation on cluster $NAME
ts_echo "About to $MODE cluster $CLUSTER_NAME (rg:$RESOURCE_GROUP)"
az aks $MODE --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --no-wait || ts_echo Ignoring any errors while doing $MODE operation on cluster $CLUSTER_NAME

ts_echo "Waiting 2 mins to give clusters time to $MODE before testing pods"
sleep 120
ts_echo $NAME
RESULT=$(az aks show --name $NAME -g $RESOURCE_GROUP | jq -r .powerState.code)
ts_echo $CLUSTER_NAME
RESULT=$(az aks show --name $CLUSTER_NAME -g $RESOURCE_GROUP | jq -r .powerState.code)
ts_echo "${RESULT}"
done
done

0 comments on commit 671378b

Please sign in to comment.