From 389fb8445666534ce5e80a887831518cecec8590 Mon Sep 17 00:00:00 2001 From: Amanda Vialva Date: Thu, 4 Apr 2024 20:05:12 -0400 Subject: [PATCH] add more GCP resource deletion --- .circleci/real_config.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.circleci/real_config.yml b/.circleci/real_config.yml index 8fbd7236958d..7e7ca412e0e4 100644 --- a/.circleci/real_config.yml +++ b/.circleci/real_config.yml @@ -2694,7 +2694,7 @@ jobs: mentions: <> channel: <> - run-gke-cluster-cleanup: + run-shared-cluster-cleanup: parameters: cluster-id: type: string @@ -2749,6 +2749,31 @@ jobs: name: Delete GCS CI Buckets command: | gsutil ls -p ${GOOGLE_PROJECT_ID} | grep -Eo "^gs://test-[a-z0-9]+-[a-z0-9]+-[0-9]-bucket" | xargs -L1 gsutil rm -r || true + - run: + name: Delete Firewall Rules + command: | + gcloud compute networks get-effective-firewalls $GCP_NETWORK_NAME --project "$GCP_PROJECT_ID" \ + --format="table(name)" | tail -n +2 | \ + while read fw; do + if [[ $fw =~ "k8s" ]]; then + gcloud compute firewall-rules delete "$fw" --quiet --project "$GCP_PROJECT_ID" + fi + done + - run: + name: Delete Forwarding Rules + command: | + gcloud compute forwarding-rules list --format="table(name)" --project "$GCP_PROJECT_ID" | tail -n +2 | \ + while read fr; do + gcloud compute forwarding-rules delete "$fr" --quiet --project "$GCP_PROJECT_ID" + done + - run: + name: Delete Target Pools + command: | + gcloud compute target-pools list --format="table(name)" --project "$GCP_PROJECT_ID" | tail -n +2 | \ + while read tp; do + gcloud compute target-pools delete "$tp" --quiet --project "$GCP_PROJECT_ID" + done + workflows: lint: @@ -3632,7 +3657,7 @@ workflows: deployment-type: efs slack-mentions: "${SLACK_USER_ID}" - - run-gke-cluster-cleanup: + - run-shared-cluster-cleanup: name: gke-cleanup context: gcp-shared-cluster