From e8278d66da5506284699ffdb334cee6c9f533ab2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 09:55:29 +0000 Subject: [PATCH 01/22] Update aidan-mundy/react-to-issue action to v1.1.2 --- .github/workflows/parsegithubissue.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/parsegithubissue.yaml b/.github/workflows/parsegithubissue.yaml index 1e22e1e5..1368492b 100644 --- a/.github/workflows/parsegithubissue.yaml +++ b/.github/workflows/parsegithubissue.yaml @@ -17,7 +17,7 @@ jobs: if: ${{ github.event.issue.user.login != 'renovate[bot]' }} steps: - name: Add eyes reaction - uses: aidan-mundy/react-to-issue@v1.1.1 + uses: aidan-mundy/react-to-issue@v1.1.2 with: issue-number: ${{ github.event.issue.number }} reactions: eyes From a6ce208cbf99251d56c725112a0bbea600656109 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Thu, 5 Oct 2023 15:14:13 +0000 Subject: [PATCH 02/22] parseissue-171 --- issues_list.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/issues_list.json b/issues_list.json index 12ca9774..c614e271 100644 --- a/issues_list.json +++ b/issues_list.json @@ -25,5 +25,13 @@ "business_area": "cross-cutting", "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" + }, + { + "skip_start_date": "05-10-2023", + "skip_end_date": "06-10-2023", + "environment": "AAT / Staging", + "business_area": "cft", + "change_jira_id": "PrL needs to be migrated to new codecept framework asap for which AAT is required to review the work", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/171" } ] \ No newline at end of file From db1ab61d754d170813ab545f49b009a9b602352e Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Fri, 6 Oct 2023 14:35:25 +0000 Subject: [PATCH 03/22] parseissue-172 --- issues_list.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/issues_list.json b/issues_list.json index c614e271..ec60968f 100644 --- a/issues_list.json +++ b/issues_list.json @@ -33,5 +33,16 @@ "business_area": "cft", "change_jira_id": "PrL needs to be migrated to new codecept framework asap for which AAT is required to review the work", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/171" + }, + { + "skip_start_date": "07-10-2023", + "skip_end_date": "08-10-2023", + "environment": [ + "AAT / Staging", + "Demo" + ], + "business_area": "cft", + "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-10947", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/172" } ] \ No newline at end of file From 132039a37a46b89a00f887aa4077471c3c2276ee Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Sat, 7 Oct 2023 18:05:50 +0000 Subject: [PATCH 04/22] housekeeping --- issues_list.json | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/issues_list.json b/issues_list.json index ec60968f..3da59d87 100644 --- a/issues_list.json +++ b/issues_list.json @@ -1,12 +1,4 @@ [ - { - "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_start_date": "11-10-2023", "skip_end_date": "11-10-2023", @@ -26,14 +18,6 @@ "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" }, - { - "skip_start_date": "05-10-2023", - "skip_end_date": "06-10-2023", - "environment": "AAT / Staging", - "business_area": "cft", - "change_jira_id": "PrL needs to be migrated to new codecept framework asap for which AAT is required to review the work", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/171" - }, { "skip_start_date": "07-10-2023", "skip_end_date": "08-10-2023", From 1211a5cbd47a788ddf0cb99e9dd2416fda4fcc60 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Mon, 9 Oct 2023 18:06:22 +0000 Subject: [PATCH 05/22] housekeeping --- issues_list.json | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/issues_list.json b/issues_list.json index 3da59d87..dfdff105 100644 --- a/issues_list.json +++ b/issues_list.json @@ -17,16 +17,5 @@ "business_area": "cross-cutting", "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" - }, - { - "skip_start_date": "07-10-2023", - "skip_end_date": "08-10-2023", - "environment": [ - "AAT / Staging", - "Demo" - ], - "business_area": "cft", - "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-10947", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/172" } ] \ No newline at end of file From aaa39a62989f2c9227f82f30c9881047f0b1d223 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Tue, 10 Oct 2023 13:53:04 +0000 Subject: [PATCH 06/22] parseissue-173 --- issues_list.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/issues_list.json b/issues_list.json index dfdff105..39ff92b0 100644 --- a/issues_list.json +++ b/issues_list.json @@ -17,5 +17,16 @@ "business_area": "cross-cutting", "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" + }, + { + "skip_start_date": "10-10-2023", + "skip_end_date": "11-10-2023", + "environment": [ + "AAT / Staging", + "Preview / Dev" + ], + "business_area": "cft", + "change_jira_id": "PrL Automation test coverage work needs to be done against AAT", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/173" } ] \ No newline at end of file From 66d13c6e8130f485d0e1e8e2a8828db54a56c0f9 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Tue, 10 Oct 2023 19:28:30 +0000 Subject: [PATCH 07/22] parseissue-174 --- issues_list.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/issues_list.json b/issues_list.json index 39ff92b0..22877006 100644 --- a/issues_list.json +++ b/issues_list.json @@ -28,5 +28,18 @@ "business_area": "cft", "change_jira_id": "PrL Automation test coverage work needs to be done against AAT", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/173" + }, + { + "skip_start_date": "12-10-2023", + "skip_end_date": "13-10-2023", + "environment": [ + "AAT / Staging", + "Preview / Dev", + "Demo", + "PTL" + ], + "business_area": "cft", + "change_jira_id": "https://mojcppprod.service-now.com/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3De3b6c76b1b29b15c6226da88b04bcb27", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/174" } ] \ No newline at end of file From bcf3e7bb1ff73c2e308ebacab9344a70caa50f40 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Wed, 11 Oct 2023 08:11:01 +0000 Subject: [PATCH 08/22] parseissue-174 --- issues_list.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/issues_list.json b/issues_list.json index 22877006..c77d904e 100644 --- a/issues_list.json +++ b/issues_list.json @@ -41,5 +41,18 @@ "business_area": "cft", "change_jira_id": "https://mojcppprod.service-now.com/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3De3b6c76b1b29b15c6226da88b04bcb27", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/174" + }, + { + "skip_start_date": "12-10-2023", + "skip_end_date": "13-10-2023", + "environment": [ + "AAT / Staging", + "Preview / Dev", + "Demo", + "PTL" + ], + "business_area": "cft", + "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-7581\n\n\nCHG5013591:\nhttps://mojcppprod.service-now.com/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3De3b6c76b1b29b15c6226da88b04bcb27", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/174" } ] \ No newline at end of file From 7c6132a0739e4d80cdf9bdd75bce6dae0bd8c015 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Thu, 12 Oct 2023 15:17:05 +0000 Subject: [PATCH 09/22] parseissue-175 --- issues_list.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/issues_list.json b/issues_list.json index c77d904e..32a5e100 100644 --- a/issues_list.json +++ b/issues_list.json @@ -54,5 +54,17 @@ "business_area": "cft", "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-7581\n\n\nCHG5013591:\nhttps://mojcppprod.service-now.com/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3De3b6c76b1b29b15c6226da88b04bcb27", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/174" + }, + { + "skip_start_date": "21-10-2023", + "skip_end_date": "22-10-2023", + "environment": [ + "AAT / Staging", + "Preview / Dev", + "Demo" + ], + "business_area": "cft", + "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-10947", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/175" } ] \ No newline at end of file From 414e445eb111eb7b14ebebb8830ef6bc659a6828 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Thu, 12 Oct 2023 18:06:01 +0000 Subject: [PATCH 10/22] housekeeping --- issues_list.json | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/issues_list.json b/issues_list.json index 32a5e100..b7417519 100644 --- a/issues_list.json +++ b/issues_list.json @@ -1,15 +1,4 @@ [ - { - "skip_start_date": "11-10-2023", - "skip_end_date": "11-10-2023", - "environment": [ - "AAT / Staging", - "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", @@ -18,17 +7,6 @@ "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" }, - { - "skip_start_date": "10-10-2023", - "skip_end_date": "11-10-2023", - "environment": [ - "AAT / Staging", - "Preview / Dev" - ], - "business_area": "cft", - "change_jira_id": "PrL Automation test coverage work needs to be done against AAT", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/173" - }, { "skip_start_date": "12-10-2023", "skip_end_date": "13-10-2023", From fbb7e639774ad68a4cddd9455d5bc3d35b5afc74 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Sat, 14 Oct 2023 18:05:48 +0000 Subject: [PATCH 11/22] housekeeping --- issues_list.json | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/issues_list.json b/issues_list.json index b7417519..438a6b93 100644 --- a/issues_list.json +++ b/issues_list.json @@ -7,32 +7,6 @@ "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" }, - { - "skip_start_date": "12-10-2023", - "skip_end_date": "13-10-2023", - "environment": [ - "AAT / Staging", - "Preview / Dev", - "Demo", - "PTL" - ], - "business_area": "cft", - "change_jira_id": "https://mojcppprod.service-now.com/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3De3b6c76b1b29b15c6226da88b04bcb27", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/174" - }, - { - "skip_start_date": "12-10-2023", - "skip_end_date": "13-10-2023", - "environment": [ - "AAT / Staging", - "Preview / Dev", - "Demo", - "PTL" - ], - "business_area": "cft", - "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-7581\n\n\nCHG5013591:\nhttps://mojcppprod.service-now.com/nav_to.do?uri=%2Fchange_request.do%3Fsys_id%3De3b6c76b1b29b15c6226da88b04bcb27", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/174" - }, { "skip_start_date": "21-10-2023", "skip_end_date": "22-10-2023", From 567442680b81ac4a3cf9f856ec0d37c1215c884b Mon Sep 17 00:00:00 2001 From: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:25:46 +0100 Subject: [PATCH 12/22] Make AKS start script more readable (#176) --- scripts/aks/manual-start.sh | 63 +++++++++++++++---------------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/scripts/aks/manual-start.sh b/scripts/aks/manual-start.sh index 91652bb4..e8fc6040 100755 --- a/scripts/aks/manual-start.sh +++ b/scripts/aks/manual-start.sh @@ -1,43 +1,30 @@ #!/usr/bin/env bash +# Define an associative array for subscription names, cluster name prefixes +declare -A SUBSCRIPTION_CLUSTERMAP + +SUBSCRIPTION_CLUSTERMAP["CFT,Sandbox"]="DCD-CFTAPPS-SBOX,CFT-SBOX" +SUBSCRIPTION_CLUSTERMAP["CFT,AAT / Staging"]="DCD-CFTAPPS-STG,CFT-AAT" +SUBSCRIPTION_CLUSTERMAP["CFT,Test / Perftest"]="DCD-CFTAPPS-TEST,CFT-PERFTEST" +SUBSCRIPTION_CLUSTERMAP["CFT,Preview / Dev"]="DCD-CFTAPPS-DEV,CFT-PREVIEW" +SUBSCRIPTION_CLUSTERMAP["CFT,Demo"]="DCD-CFTAPPS-DEMO,CFT-DEMO" +SUBSCRIPTION_CLUSTERMAP["CFT,ITHC"]="DCD-CFTAPPS-ITHC,CFT-ITHC" +SUBSCRIPTION_CLUSTERMAP["CFT,PTL"]="DTS-CFTPTL-INTSVC,CFT-PTL" +SUBSCRIPTION_CLUSTERMAP["CFT,PTLSBOX"]="DTS-CFTSBOX-INTSVC,CFT-PTLSBOX" + +SUBSCRIPTION_CLUSTERMAP["SDS,Sandbox"]="DTS-SHAREDSERVICES-SBOX,SS-SBOX" +SUBSCRIPTION_CLUSTERMAP["SDS,AAT / Staging"]="DTS-SHAREDSERVICES-STG,SS-STG" +SUBSCRIPTION_CLUSTERMAP["SDS,Test / Perftest"]="DTS-SHAREDSERVICES-TEST,SS-TEST" +SUBSCRIPTION_CLUSTERMAP["SDS,Preview / Dev"]="DTS-SHAREDSERVICES-DEV,SS-DEV" +SUBSCRIPTION_CLUSTERMAP["SDS,Demo"]="DTS-SHAREDSERVICES-DEMO,SS-DEMO" +SUBSCRIPTION_CLUSTERMAP["SDS,ITHC"]="DTS-SHAREDSERVICES-ITHC,SS-ITHC" +SUBSCRIPTION_CLUSTERMAP["SDS,PTL"]="DTS-SHAREDSERVICESPTL,SS-PTL" +SUBSCRIPTION_CLUSTERMAP["SDS,PTLSBOX"]="DTS-SHAREDSERVICESPTL-SBOX,SS-PTLSBOX" + function subscription() { - if [[ $SELECTED_ENV =~ "Test / Perftest" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SELECTED_ENV="test" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "Test / Perftest" && $PROJECT == "CFT" ]]; then - SELECTED_ENV="perftest" - SUBSCRIPTION="DCD-CFTAPPS-TEST" - elif [[ $SELECTED_ENV =~ "Preview / Dev" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SELECTED_ENV="DEV" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "Preview / Dev" && $PROJECT == "CFT" ]]; then - SELECTED_ENV="DEV" - SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "AAT / Staging" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SELECTED_ENV="stg" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "AAT / Staging" && $PROJECT == "CFT" ]]; then - SELECTED_ENV="stg" - SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "PTLSBOX" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SUBSCRIPTION="DTS-SHAREDSERVICESPTL-SBOX" - elif [[ $SELECTED_ENV =~ "PLTSBOX" && $PROJECT == "CFT" ]]; then - SUBSCRIPTION="DTS-CFTSBOX-INTSVC" - elif [[ $SELECTED_ENV =~ "PTL" && $PROJECT == "CFT" ]]; then - SUBSCRIPTION="DTS-CFTPTL-INTSVC" - elif [[ $SELECTED_ENV == "PTL" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SUBSCRIPTION="DTS-SHAREDSERVICESPTL" - elif [[ $SELECTED_ENV != "Test / Perftest" && $SELECTED_ENV != "Preview / Dev" && $SELECTED_ENV != "AAT / Staging" && $SELECTED_ENV != "PTL" && $SELECTED_ENV != "PLTSBOX" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV != "Test / Perftest" && $SELECTED_ENV != "Preview / Dev" && $SELECTED_ENV != "AAT / Staging" && $SELECTED_ENV != "PTL" && $SELECTED_ENV != "PLTSBOX" && $PROJECT == "CFT" ]]; then - SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV" - fi + key="${PROJECT},${SELECTED_ENV}" + SUBSCRIPTION=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 1) + CLUSTER_PREFIX=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 2) if [[ $INSTANCES == 'All' ]]; then INSTANCES=(00 01) @@ -59,7 +46,7 @@ function ts_echo() { subscription for INSTANCE in ${INSTANCES[@]}; do CLUSTERS=$(az resource list \ - --name $PROJECT"-"$SELECTED_ENV"-"$INSTANCE"-aks" \ + --name $CLUSTER_PREFIX"-"$INSTANCE"-aks" \ --query "[?tags.autoShutdown == 'true']" -o json) jq -c '.[]' <<<$CLUSTERS | while read cluster; do cluster From 4ac41a8325cc0522540d94d50a213fb29a059450 Mon Sep 17 00:00:00 2001 From: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:08:00 +0100 Subject: [PATCH 13/22] Use same script for manual start stop (#177) --- .github/workflows/aks-manual-shutdown.yaml | 2 +- .github/workflows/aks-manual-start.yaml | 2 +- .github/workflows/manual-start.yaml | 2 +- scripts/aks/manual-shutdown.sh | 76 ------------------- .../{manual-start.sh => manual-start-stop.sh} | 13 +++- 5 files changed, 13 insertions(+), 82 deletions(-) delete mode 100755 scripts/aks/manual-shutdown.sh rename scripts/aks/{manual-start.sh => manual-start-stop.sh} (84%) diff --git a/.github/workflows/aks-manual-shutdown.yaml b/.github/workflows/aks-manual-shutdown.yaml index 8684d4cb..cf1926ca 100644 --- a/.github/workflows/aks-manual-shutdown.yaml +++ b/.github/workflows/aks-manual-shutdown.yaml @@ -46,4 +46,4 @@ jobs: tenant-id: 531ff96d-0ae9-462a-8d2d-bec7c0b42082 # HMCTS.NET allow-no-subscriptions: true - name: AKS Manual Stop - run: ./scripts/aks/manual-shutdown.sh + run: ./scripts/aks/manual-start-stop.sh stop diff --git a/.github/workflows/aks-manual-start.yaml b/.github/workflows/aks-manual-start.yaml index e3df20e7..d98001cb 100644 --- a/.github/workflows/aks-manual-start.yaml +++ b/.github/workflows/aks-manual-start.yaml @@ -46,4 +46,4 @@ jobs: tenant-id: 531ff96d-0ae9-462a-8d2d-bec7c0b42082 # HMCTS.NET allow-no-subscriptions: true - name: AKS Manual Start - run: ./scripts/aks/manual-start.sh ${{ secrets.REGISTRYSLACKWEBHOOK }} + run: ./scripts/aks/manual-start-stop.sh start diff --git a/.github/workflows/manual-start.yaml b/.github/workflows/manual-start.yaml index c82d9391..e79fc9fe 100644 --- a/.github/workflows/manual-start.yaml +++ b/.github/workflows/manual-start.yaml @@ -46,7 +46,7 @@ jobs: tenant-id: 531ff96d-0ae9-462a-8d2d-bec7c0b42082 # HMCTS.NET allow-no-subscriptions: true - name: AKS Manual Start in ${{ inputs.PROJECT }} ${{ inputs.SELECTED_ENV }} Environment - run: ./scripts/aks/manual-start.sh + run: ./scripts/aks/manual-start-stop.sh start appgateway: runs-on: ubuntu-latest steps: diff --git a/scripts/aks/manual-shutdown.sh b/scripts/aks/manual-shutdown.sh deleted file mode 100755 index 4c06909a..00000000 --- a/scripts/aks/manual-shutdown.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash - -function subscription() { - if [[ $SELECTED_ENV =~ "Test / Perftest" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SELECTED_ENV="test" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "Test / Perftest" && $PROJECT == "CFT" ]]; then - SELECTED_ENV="perftest" - SUBSCRIPTION="DCD-CFTAPPS-TEST" - elif [[ $SELECTED_ENV =~ "Preview / Dev" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SELECTED_ENV="DEV" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "Preview / Dev" && $PROJECT == "CFT" ]]; then - SELECTED_ENV="DEV" - SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "AAT / Staging" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SELECTED_ENV="stg" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "AAT / Staging" && $PROJECT == "CFT" ]]; then - SELECTED_ENV="stg" - SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV" - elif [[ $SELECTED_ENV =~ "PTLSBOX" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SUBSCRIPTION="DTS-SHAREDSERVICESPTL-SBOX" - elif [[ $SELECTED_ENV =~ "PLTSBOX" && $PROJECT == "CFT" ]]; then - SUBSCRIPTION="DTS-CFTSBOX-INTSVC" - elif [[ $SELECTED_ENV =~ "PTL" && $PROJECT == "CFT" ]]; then - SUBSCRIPTION="DTS-CFTPTL-INTSVC" - elif [[ $SELECTED_ENV == "PTL" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SUBSCRIPTION="DTS-SHAREDSERVICESPTL" - elif [[ $SELECTED_ENV != "Test / Perftest" && $SELECTED_ENV != "Preview / Dev" && $SELECTED_ENV != "AAT / Staging" && $SELECTED_ENV != "PTL" && $SELECTED_ENV != "PLTSBOX" && $PROJECT == "SDS" ]]; then - PROJECT="ss" - SUBSCRIPTION="DTS-SHAREDSERVICES-$SELECTED_ENV" - elif [[ $SELECTED_ENV != "Test / Perftest" && $SELECTED_ENV != "Preview / Dev" && $SELECTED_ENV != "AAT / Staging" && $SELECTED_ENV != "PTL" && $SELECTED_ENV != "PLTSBOX" && $PROJECT == "CFT" ]]; then - SUBSCRIPTION="DCD-CFTAPPS-$SELECTED_ENV" - fi - - if [[ $INSTANCES == 'All' ]]; then - INSTANCES=(00 01) - fi - - az account set -n $SUBSCRIPTION - ts_echo $SUBSCRIPTION selected -} - -function cluster() { - RESOURCE_GROUP=$(jq -r '.resourceGroup' <<<$cluster) - NAME=$(jq -r '.name' <<<$cluster) -} - -function ts_echo() { - date +"%H:%M:%S $(printf "%s " "$@")" -} - -subscription -for INSTANCE in ${INSTANCES[@]}; do - CLUSTERS=$(az resource list \ - --name $PROJECT"-"$SELECTED_ENV"-"$INSTANCE"-aks" \ - --query "[?tags.autoShutdown == 'true']" -o json) - jq -c '.[]' <<<$CLUSTERS | while read cluster; do - cluster - - ts_echo "About to stop cluster $NAME (rg:$RESOURCE_GROUP)" - az aks stop --resource-group $RESOURCE_GROUP --name $NAME --no-wait || ts_echo Ignoring any errors starting cluster $NAME - - ts_echo "Waiting 2 mins to give clusters time to stop 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 diff --git a/scripts/aks/manual-start.sh b/scripts/aks/manual-start-stop.sh similarity index 84% rename from scripts/aks/manual-start.sh rename to scripts/aks/manual-start-stop.sh index e8fc6040..cae2e977 100755 --- a/scripts/aks/manual-start.sh +++ b/scripts/aks/manual-start-stop.sh @@ -43,6 +43,13 @@ function ts_echo() { date +"%H:%M:%S $(printf "%s " "$@")" } +MODE=${1:-start} + +if [[ "$MODE" != "start" && "$MODE" != "stop" ]]; then + echo "Invalid MODE. Please use 'start' or 'stop'." + exit 1 +fi + subscription for INSTANCE in ${INSTANCES[@]}; do CLUSTERS=$(az resource list \ @@ -51,10 +58,10 @@ for INSTANCE in ${INSTANCES[@]}; do 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 $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 start before testing pods" + 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) From e2f74d1e343629f4da60955172180669ebe19181 Mon Sep 17 00:00:00 2001 From: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:55:54 +0100 Subject: [PATCH 14/22] split subscription selection code into a seperate file and reuse (#178) --- scripts/aks/manual-start-stop.sh | 47 ++++++-------------------------- scripts/aks/resource-details.sh | 47 ++++---------------------------- scripts/aks/set-subscription.sh | 35 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 80 deletions(-) create mode 100644 scripts/aks/set-subscription.sh diff --git a/scripts/aks/manual-start-stop.sh b/scripts/aks/manual-start-stop.sh index cae2e977..7c7d792f 100755 --- a/scripts/aks/manual-start-stop.sh +++ b/scripts/aks/manual-start-stop.sh @@ -1,48 +1,12 @@ #!/usr/bin/env bash -# Define an associative array for subscription names, cluster name prefixes -declare -A SUBSCRIPTION_CLUSTERMAP - -SUBSCRIPTION_CLUSTERMAP["CFT,Sandbox"]="DCD-CFTAPPS-SBOX,CFT-SBOX" -SUBSCRIPTION_CLUSTERMAP["CFT,AAT / Staging"]="DCD-CFTAPPS-STG,CFT-AAT" -SUBSCRIPTION_CLUSTERMAP["CFT,Test / Perftest"]="DCD-CFTAPPS-TEST,CFT-PERFTEST" -SUBSCRIPTION_CLUSTERMAP["CFT,Preview / Dev"]="DCD-CFTAPPS-DEV,CFT-PREVIEW" -SUBSCRIPTION_CLUSTERMAP["CFT,Demo"]="DCD-CFTAPPS-DEMO,CFT-DEMO" -SUBSCRIPTION_CLUSTERMAP["CFT,ITHC"]="DCD-CFTAPPS-ITHC,CFT-ITHC" -SUBSCRIPTION_CLUSTERMAP["CFT,PTL"]="DTS-CFTPTL-INTSVC,CFT-PTL" -SUBSCRIPTION_CLUSTERMAP["CFT,PTLSBOX"]="DTS-CFTSBOX-INTSVC,CFT-PTLSBOX" - -SUBSCRIPTION_CLUSTERMAP["SDS,Sandbox"]="DTS-SHAREDSERVICES-SBOX,SS-SBOX" -SUBSCRIPTION_CLUSTERMAP["SDS,AAT / Staging"]="DTS-SHAREDSERVICES-STG,SS-STG" -SUBSCRIPTION_CLUSTERMAP["SDS,Test / Perftest"]="DTS-SHAREDSERVICES-TEST,SS-TEST" -SUBSCRIPTION_CLUSTERMAP["SDS,Preview / Dev"]="DTS-SHAREDSERVICES-DEV,SS-DEV" -SUBSCRIPTION_CLUSTERMAP["SDS,Demo"]="DTS-SHAREDSERVICES-DEMO,SS-DEMO" -SUBSCRIPTION_CLUSTERMAP["SDS,ITHC"]="DTS-SHAREDSERVICES-ITHC,SS-ITHC" -SUBSCRIPTION_CLUSTERMAP["SDS,PTL"]="DTS-SHAREDSERVICESPTL,SS-PTL" -SUBSCRIPTION_CLUSTERMAP["SDS,PTLSBOX"]="DTS-SHAREDSERVICESPTL-SBOX,SS-PTLSBOX" - -function subscription() { - key="${PROJECT},${SELECTED_ENV}" - SUBSCRIPTION=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 1) - CLUSTER_PREFIX=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 2) - - if [[ $INSTANCES == 'All' ]]; then - INSTANCES=(00 01) - fi - - az account set -n $SUBSCRIPTION - ts_echo $SUBSCRIPTION selected -} +source scripts/aks/set-subscription.sh function cluster() { RESOURCE_GROUP=$(jq -r '.resourceGroup' <<<$cluster) NAME=$(jq -r '.name' <<<$cluster) } -function ts_echo() { - date +"%H:%M:%S $(printf "%s " "$@")" -} - MODE=${1:-start} if [[ "$MODE" != "start" && "$MODE" != "stop" ]]; then @@ -50,7 +14,12 @@ if [[ "$MODE" != "start" && "$MODE" != "stop" ]]; then exit 1 fi -subscription + +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" \ @@ -67,4 +36,4 @@ for INSTANCE in ${INSTANCES[@]}; do RESULT=$(az aks show --name $NAME -g $RESOURCE_GROUP | jq -r .powerState.code) ts_echo "${RESULT}" done -done +done \ No newline at end of file diff --git a/scripts/aks/resource-details.sh b/scripts/aks/resource-details.sh index 7de78097..b5088867 100755 --- a/scripts/aks/resource-details.sh +++ b/scripts/aks/resource-details.sh @@ -9,6 +9,7 @@ business_area_entry=$(jq -r '. | last | .business_area' issues_list.json) #declare associative array declare -A sku_sizes +source scripts/aks/set-subscription.sh #Function to add SKU and node count to array. #Create new entry if SKU does not already exist. Update entry if SKU already exists in array. function countSku() { @@ -66,49 +67,13 @@ function get_costs() { #Set subscription based on user entry. #If statements used to deal with subscription naming convention and enviornment dropdown values. Eg "AAT / Staging" while read i; do + PROJECT="CFT" if [[ $business_area_entry =~ "Cross-Cutting" ]]; then - echo "processing $i in $business_area_entry" - if [[ $i =~ "Staging" ]]; then - az account set --name DTS-SHAREDSERVICES-STG - get_costs - elif [[ $i =~ "dev" ]]; then - az account set --name DTS-SHAREDSERVICES-DEV - get_costs - elif [[ $i =~ "test" ]]; then - az account set --name DTS-SHAREDSERVICES-TEST - get_costs - elif [[ $i =~ "sandbox" ]]; then - az account set --name DTS-SHAREDSERVICES-SBOX - get_costs - elif [[ $i == "ptl" ]]; then - az account set --name DTS-SHAREDSERVICESPTL - get_costs - else - az account set --name DTS-SHAREDSERVICES-$i - get_costs - fi - elif [[ $business_area_entry =~ "CFT" ]]; then - echo "processing $i" - if [[ $i =~ "AAT" ]]; then - az account set --name DCD-CFTAPPS-STG - get_costs - elif [[ $i =~ "Preview" ]]; then - az account set --name DCD-CFTAPPS-DEV - get_costs - elif [[ $i =~ "Perftest" ]]; then - az account set --name DCD-CFTAPPS-TEST - get_costs - elif [[ $i =~ "Sandbox" ]]; then - az account set --name DCD-CFTAPPS-SBOX - get_costs - elif [[ $i == "ptl" ]]; then - az account set --name DTS-CFTPTL-INTSVC - get_costs - else - az account set --name DCD-CFTAPPS-$i - get_costs - fi + PROJECT="SDS" fi + SELECTED_ENV=$i + subscription + get_costs done < <(jq -r 'last | .environment[]' issues_list.json || jq -r 'last | .environment' issues_list.json) #Add GitHub env vars diff --git a/scripts/aks/set-subscription.sh b/scripts/aks/set-subscription.sh new file mode 100644 index 00000000..1489ea1a --- /dev/null +++ b/scripts/aks/set-subscription.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Define an associative array for subscription names, cluster name prefixes +declare -A SUBSCRIPTION_CLUSTERMAP + +SUBSCRIPTION_CLUSTERMAP["CFT,Sandbox"]="DCD-CFTAPPS-SBOX,CFT-SBOX" +SUBSCRIPTION_CLUSTERMAP["CFT,AAT / Staging"]="DCD-CFTAPPS-STG,CFT-AAT" +SUBSCRIPTION_CLUSTERMAP["CFT,Test / Perftest"]="DCD-CFTAPPS-TEST,CFT-PERFTEST" +SUBSCRIPTION_CLUSTERMAP["CFT,Preview / Dev"]="DCD-CFTAPPS-DEV,CFT-PREVIEW" +SUBSCRIPTION_CLUSTERMAP["CFT,Demo"]="DCD-CFTAPPS-DEMO,CFT-DEMO" +SUBSCRIPTION_CLUSTERMAP["CFT,ITHC"]="DCD-CFTAPPS-ITHC,CFT-ITHC" +SUBSCRIPTION_CLUSTERMAP["CFT,PTL"]="DTS-CFTPTL-INTSVC,CFT-PTL" +SUBSCRIPTION_CLUSTERMAP["CFT,PTLSBOX"]="DTS-CFTSBOX-INTSVC,CFT-PTLSBOX" + +SUBSCRIPTION_CLUSTERMAP["SDS,Sandbox"]="DTS-SHAREDSERVICES-SBOX,SS-SBOX" +SUBSCRIPTION_CLUSTERMAP["SDS,AAT / Staging"]="DTS-SHAREDSERVICES-STG,SS-STG" +SUBSCRIPTION_CLUSTERMAP["SDS,Test / Perftest"]="DTS-SHAREDSERVICES-TEST,SS-TEST" +SUBSCRIPTION_CLUSTERMAP["SDS,Preview / Dev"]="DTS-SHAREDSERVICES-DEV,SS-DEV" +SUBSCRIPTION_CLUSTERMAP["SDS,Demo"]="DTS-SHAREDSERVICES-DEMO,SS-DEMO" +SUBSCRIPTION_CLUSTERMAP["SDS,ITHC"]="DTS-SHAREDSERVICES-ITHC,SS-ITHC" +SUBSCRIPTION_CLUSTERMAP["SDS,PTL"]="DTS-SHAREDSERVICESPTL,SS-PTL" +SUBSCRIPTION_CLUSTERMAP["SDS,PTLSBOX"]="DTS-SHAREDSERVICESPTL-SBOX,SS-PTLSBOX" + +function subscription() { + key="${PROJECT},${SELECTED_ENV}" + SUBSCRIPTION=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 1) + CLUSTER_PREFIX=$(echo ${SUBSCRIPTION_CLUSTERMAP[$key]} | cut -d ',' -f 2) + + az account set -n $SUBSCRIPTION + ts_echo $SUBSCRIPTION selected +} + +function ts_echo() { + date +"%H:%M:%S $(printf "%s " "$@")" +} \ No newline at end of file From aa482771cd04b95f552414c77d1223dc547403aa Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Thu, 19 Oct 2023 14:32:29 +0000 Subject: [PATCH 15/22] parseissue-179 --- issues_list.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/issues_list.json b/issues_list.json index 438a6b93..33994fd5 100644 --- a/issues_list.json +++ b/issues_list.json @@ -18,5 +18,17 @@ "business_area": "cft", "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-10947", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/175" + }, + { + "skip_start_date": "19-10-2023", + "skip_end_date": "19-10-2023", + "environment": [ + "AAT / Staging", + "Preview / Dev", + "PTL" + ], + "business_area": "cft", + "change_jira_id": "DFPL-1561", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/179" } ] \ No newline at end of file From d0204bdbff2ce3a9d13d07195d2b6b37d4668c46 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Thu, 19 Oct 2023 14:53:03 +0000 Subject: [PATCH 16/22] parseissue-180 --- issues_list.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/issues_list.json b/issues_list.json index 33994fd5..74f3940b 100644 --- a/issues_list.json +++ b/issues_list.json @@ -30,5 +30,16 @@ "business_area": "cft", "change_jira_id": "DFPL-1561", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/179" + }, + { + "skip_start_date": "22-10-2023", + "skip_end_date": "23-10-2023", + "environment": [ + "AAT / Staging", + "Preview / Dev" + ], + "business_area": "cft", + "change_jira_id": "Test change", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/180" } ] \ No newline at end of file From ab37c78503ba89e721ef0754fd407f21a5933a94 Mon Sep 17 00:00:00 2001 From: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:57:18 +0100 Subject: [PATCH 17/22] Update issues_list.json (#181) --- issues_list.json | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/issues_list.json b/issues_list.json index 74f3940b..145febf4 100644 --- a/issues_list.json +++ b/issues_list.json @@ -30,16 +30,5 @@ "business_area": "cft", "change_jira_id": "DFPL-1561", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/179" - }, - { - "skip_start_date": "22-10-2023", - "skip_end_date": "23-10-2023", - "environment": [ - "AAT / Staging", - "Preview / Dev" - ], - "business_area": "cft", - "change_jira_id": "Test change", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/180" } -] \ No newline at end of file +] From 079eec6e1a0152c2b257fbceab727b07c3784b6c Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Thu, 19 Oct 2023 18:06:09 +0000 Subject: [PATCH 18/22] housekeeping --- issues_list.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/issues_list.json b/issues_list.json index 145febf4..33994fd5 100644 --- a/issues_list.json +++ b/issues_list.json @@ -31,4 +31,4 @@ "change_jira_id": "DFPL-1561", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/179" } -] +] \ No newline at end of file From 48031802d24b2656f7ee5de359055b77f6144ad5 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Fri, 20 Oct 2023 18:06:11 +0000 Subject: [PATCH 19/22] housekeeping --- issues_list.json | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/issues_list.json b/issues_list.json index 33994fd5..438a6b93 100644 --- a/issues_list.json +++ b/issues_list.json @@ -18,17 +18,5 @@ "business_area": "cft", "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-10947", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/175" - }, - { - "skip_start_date": "19-10-2023", - "skip_end_date": "19-10-2023", - "environment": [ - "AAT / Staging", - "Preview / Dev", - "PTL" - ], - "business_area": "cft", - "change_jira_id": "DFPL-1561", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/179" } ] \ No newline at end of file From 209d66e024d21464f6e3434323024a0b35e20b51 Mon Sep 17 00:00:00 2001 From: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:11:32 +0100 Subject: [PATCH 20/22] Refactor auto start script (#183) * Refactor auto start script * fix --- scripts/aks/auto-start.sh | 154 ++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 82 deletions(-) diff --git a/scripts/aks/auto-start.sh b/scripts/aks/auto-start.sh index 3063f012..994a115b 100755 --- a/scripts/aks/auto-start.sh +++ b/scripts/aks/auto-start.sh @@ -1,18 +1,16 @@ #!/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() { @@ -20,85 +18,77 @@ function ts_echo() { } 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 From 1a2e4751c47ad4a4e0a7e13b1d7ddf301da6d3c8 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Mon, 23 Oct 2023 18:06:01 +0000 Subject: [PATCH 21/22] housekeeping --- issues_list.json | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/issues_list.json b/issues_list.json index 438a6b93..66e726fd 100644 --- a/issues_list.json +++ b/issues_list.json @@ -6,17 +6,5 @@ "business_area": "cross-cutting", "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" - }, - { - "skip_start_date": "21-10-2023", - "skip_end_date": "22-10-2023", - "environment": [ - "AAT / Staging", - "Preview / Dev", - "Demo" - ], - "business_area": "cft", - "change_jira_id": "https://tools.hmcts.net/jira/browse/CIV-10947", - "issue_link": "https://github.com/hmcts/auto-shutdown/issues/175" } ] \ No newline at end of file From e6030e53880288ae86ff63898e9ef2dbed621584 Mon Sep 17 00:00:00 2001 From: hmcts-platform-operations Date: Tue, 24 Oct 2023 12:44:27 +0000 Subject: [PATCH 22/22] parseissue-184 --- issues_list.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/issues_list.json b/issues_list.json index 66e726fd..b936ebe3 100644 --- a/issues_list.json +++ b/issues_list.json @@ -6,5 +6,18 @@ "business_area": "cross-cutting", "change_jira_id": "DTSPO-15384", "issue_link": "https://github.com/hmcts/auto-shutdown/issues/168" + }, + { + "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": "CHG5013849", + "issue_link": "https://github.com/hmcts/auto-shutdown/issues/184" } ] \ No newline at end of file