-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into renovate/actions-checkout-4.x
- Loading branch information
Showing
11 changed files
with
167 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ jobs: | |
if: ${{ github.event.issue.user.login != 'renovate[bot]' }} | ||
steps: | ||
- name: Add eyes reaction | ||
uses: aidan-mundy/[email protected].1 | ||
uses: aidan-mundy/[email protected].2 | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
reactions: eyes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
[ | ||
{ | ||
"skip_start_date": "02-10-2023", | ||
"skip_end_date": "06-10-2023", | ||
"environment": "Preview / Dev", | ||
"business_area": "cft", | ||
"change_jira_id": "Requested by Robin to be kept on Monday-Friday until we have Preview postgresl change", | ||
"issue_link": "https://github.com/hmcts/auto-shutdown/issues/155" | ||
"skip_end_date": "03-11-2023", | ||
"environment": "Test / Perftest", | ||
"business_area": "cross-cutting", | ||
"change_jira_id": "DTSPO-15384", | ||
"issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" | ||
}, | ||
{ | ||
"skip_start_date": "11-10-2023", | ||
"skip_end_date": "11-10-2023", | ||
"skip_start_date": "24-10-2023", | ||
"skip_end_date": "25-10-2023", | ||
"environment": [ | ||
"AAT / Staging", | ||
"Preview / Dev", | ||
"Demo", | ||
"PTL" | ||
], | ||
"business_area": "cft", | ||
"change_jira_id": "RR-3278 - CCD 31.1.0 (Cache move to Caffeine) Release", | ||
"issue_link": "https://github.com/hmcts/auto-shutdown/issues/159" | ||
}, | ||
{ | ||
"skip_start_date": "02-10-2023", | ||
"skip_end_date": "03-11-2023", | ||
"environment": "Test / Perftest", | ||
"business_area": "cross-cutting", | ||
"change_jira_id": "DTSPO-15384", | ||
"issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" | ||
"change_jira_id": "CHG5013849", | ||
"issue_link": "https://github.com/hmcts/auto-shutdown/issues/184" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,94 @@ | ||
#!/usr/bin/env bash | ||
|
||
registrySlackWebhook=$1 | ||
|
||
function subscription () { | ||
|
||
SUBSCRIPTION_ID=$(jq -r '.id' <<< $subscription) | ||
az account set -s $SUBSCRIPTION_ID | ||
CLUSTERS=$(az resource list \ | ||
--resource-type Microsoft.ContainerService/managedClusters \ | ||
--query "[?tags.autoShutdown == 'true']" -o json) | ||
function subscription() { | ||
SUBSCRIPTION_ID=$(jq -r '.id' <<< $subscription) | ||
az account set -s $SUBSCRIPTION_ID | ||
CLUSTERS=$(az resource list --resource-type Microsoft.ContainerService/managedClusters --query "[?tags.autoShutdown == 'true']" -o json) | ||
} | ||
|
||
function cluster () { | ||
RESOURCE_GROUP=$(jq -r '.resourceGroup' <<< $cluster) | ||
NAME=$(jq -r '.name' <<< $cluster) | ||
function cluster() { | ||
RESOURCE_GROUP=$(jq -r '.resourceGroup' <<< $cluster) | ||
NAME=$(jq -r '.name' <<< $cluster) | ||
} | ||
|
||
function ts_echo() { | ||
date +"%H:%M:%S $(printf "%s " "$@")" | ||
} | ||
|
||
function notification() { | ||
ts_echo "$APP works in $ENVIRONMENT after $NAME start-up" | ||
curl -X POST --data-urlencode "payload={\"channel\": \"#aks-monitor-$ENV\", \"username\": \"AKS Auto-Start\", \"text\": \"$APP works in $ENVIRONMENT after $NAME start-up.\", \"icon_emoji\": \":tim-webster:\"}" \ | ||
${registrySlackWebhook} | ||
local channel="$1" | ||
local message="$2" | ||
curl -X POST --data-urlencode "payload={\"channel\": \"$channel\", \"username\": \"AKS Auto-Start\", \"text\": \"$message\", \"icon_emoji\": \":tim-webster:\"}" \ | ||
${registrySlackWebhook} | ||
} | ||
|
||
SUBSCRIPTIONS=$(az account list -o json) | ||
jq -c '.[]' <<< $SUBSCRIPTIONS | while read subscription; do | ||
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 | ||
done | ||
done | ||
|
||
echo "Waiting 10 mins to give clusters time to start before testing pods" | ||
sleep 600 | ||
|
||
# Tests | ||
jq -c '.[]' <<< $SUBSCRIPTIONS | while read subscription; do | ||
subscription | ||
jq -c '.[]' <<< $CLUSTERS | while read cluster; do | ||
cluster | ||
|
||
BUSINESS_AREA=$(jq -r '.tags.businessArea' <<< $cluster) | ||
if [[ "$BUSINESS_AREA" == "Cross-Cutting" ]]; then | ||
APP="toffee" | ||
elif [[ "$BUSINESS_AREA" == "CFT" ]]; then | ||
APP="plum" | ||
fi | ||
function check_cluster_status() { | ||
BUSINESS_AREA=$(jq -r '.tags.businessArea' <<< $cluster) | ||
if [[ "$BUSINESS_AREA" == "Cross-Cutting" ]]; then | ||
APP="toffee" | ||
elif [[ "$BUSINESS_AREA" == "CFT" ]]; then | ||
APP="plum" | ||
fi | ||
|
||
ENVIRONMENT=$(jq -r '.tags.environment' <<< $cluster) | ||
ENVIRONMENT=$(jq -r '.tags.environment' <<< $cluster) | ||
|
||
if [[ "$ENVIRONMENT" == "sandbox" || "$ENVIRONMENT" == "Sandbox" ]]; then | ||
ENV="sbox" | ||
elif [[ "$ENVIRONMENT" == "testing" ]]; then | ||
ENV="perftest" | ||
elif [[ "$ENVIRONMENT" == "staging" ]]; then | ||
ENV="aat" | ||
else | ||
ENV="$ENVIRONMENT" | ||
fi | ||
local env_variants=( | ||
"sandbox/Sandbox:sbox" | ||
"testing/toffee:toffee.test" | ||
"testing/plum:plum.perftest" | ||
"staging/toffee:toffee.staging" | ||
"staging/plum:plum.aat" | ||
) | ||
|
||
ts_echo "Test that $APP works in $ENVIRONMENT after $NAME start-up" | ||
if [[ "$ENVIRONMENT" == "testing" && "$APP" == "toffee" ]]; then | ||
APPLICATION="$APP.test" | ||
elif [[ "$ENVIRONMENT" == "testing" && "$APP" == "plum" ]]; then | ||
APPLICATION="$APP.perftest" | ||
elif [[ "$ENVIRONMENT" == "staging" && "$APP" == "toffee" ]]; then | ||
APPLICATION="$APP.staging" | ||
elif [[ "$ENVIRONMENT" == "staging" && "$APP" == "plum" ]]; then | ||
APPLICATION="$APP.aat" | ||
else | ||
for variant in "${env_variants[@]}"; do | ||
parts=(${variant//:/ }) | ||
if [[ "$ENVIRONMENT/$APP" == "${parts[0]}" ]]; then | ||
APPLICATION="${parts[1]}" | ||
break | ||
else | ||
APPLICATION="$APP.$ENVIRONMENT" | ||
fi | ||
done | ||
|
||
statuscode=$(curl --max-time 30 --retry 20 --retry-delay 15 -s -o /dev/null -w "%{http_code}" https://$APPLICATION.platform.hmcts.net) | ||
ts_echo "Test that $APP works in $ENVIRONMENT after $NAME start-up" | ||
|
||
if [[ "$ENVIRONMENT" == "demo" && $statuscode -eq 302 ]]; then | ||
notification | ||
elif [[ $statuscode -eq 200 ]]; then | ||
notification | ||
else | ||
ts_echo "$APP does not work in $ENVIRONMENT after $NAME start-up" | ||
curl -X POST --data-urlencode "payload={\"channel\": \"#green-daily-checks\", \"username\": \"AKS Auto-Start\", \"text\": \"$APP does not work in $ENVIRONMENT after $NAME start-up. Please check cluster.\", \"icon_emoji\": \":tim-webster:\"}" \ | ||
${registrySlackWebhook} | ||
curl -X POST --data-urlencode "payload={\"channel\": \"#aks-monitor-$ENV\", \"username\": \"AKS Auto-Start\", \"text\": \"$APP does not work in $ENVIRONMENT after $NAME start-up. Please check cluster.\", \"icon_emoji\": \":tim-webster:\"}" \ | ||
${registrySlackWebhook} | ||
fi | ||
done | ||
done | ||
|
||
#Summary | ||
jq -c '.[]' <<< $SUBSCRIPTIONS | while read subscription; do | ||
subscription | ||
jq -c '.[]' <<< $CLUSTERS | while read cluster; do | ||
cluster | ||
ts_echo $NAME | ||
RESULT=$(az aks show --name $NAME -g $RESOURCE_GROUP | jq -r .powerState.code) | ||
ts_echo "${RESULT}" | ||
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" | ||
else | ||
message="$APP does not work in $ENVIRONMENT after $NAME start-up. Please check cluster." | ||
ts_echo "$message" | ||
notification "#green-daily-checks" "$message" | ||
notification "#aks-monitor-$ENV" "$message" | ||
fi | ||
} | ||
|
||
function process_clusters() { | ||
jq -c '.[]' <<< $SUBSCRIPTIONS | while read subscription; do | ||
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 | ||
done | ||
done | ||
done | ||
|
||
echo "Waiting 10 mins to give clusters time to start before testing pods" | ||
sleep 600 | ||
|
||
jq -c '.[]' <<< $SUBSCRIPTIONS | while read subscription; do | ||
subscription | ||
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}" | ||
done | ||
done | ||
} | ||
|
||
SUBSCRIPTIONS=$(az account list -o json) | ||
process_clusters |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
source scripts/aks/set-subscription.sh | ||
|
||
function cluster() { | ||
RESOURCE_GROUP=$(jq -r '.resourceGroup' <<<$cluster) | ||
NAME=$(jq -r '.name' <<<$cluster) | ||
} | ||
|
||
MODE=${1:-start} | ||
|
||
if [[ "$MODE" != "start" && "$MODE" != "stop" ]]; then | ||
echo "Invalid MODE. Please use 'start' or 'stop'." | ||
exit 1 | ||
fi | ||
|
||
|
||
if [[ $INSTANCES == 'All' ]]; then | ||
INSTANCES=(00 01) | ||
fi | ||
|
||
subscription # Call the subscription function from the included script | ||
for INSTANCE in ${INSTANCES[@]}; do | ||
CLUSTERS=$(az resource list \ | ||
--name $CLUSTER_PREFIX"-"$INSTANCE"-aks" \ | ||
--query "[?tags.autoShutdown == 'true']" -o json) | ||
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 "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 "${RESULT}" | ||
done | ||
done |
Oops, something went wrong.