summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher A. Snapp <csnapp@chef.io>2020-06-01 11:05:03 -0600
committerChristopher A. Snapp <csnapp@chef.io>2020-06-01 11:05:03 -0600
commit46811e3acf7373cd7d8adefc55f927f4e0ff1f12 (patch)
tree8bb4e99462652e357dc318268c3a07372a354049
parentcb57400ec0048a162909875b769b7366cdd30204 (diff)
downloadchef-46811e3acf7373cd7d8adefc55f927f4e0ff1f12.tar.gz
Add nightly cleanup of orphaned test resourcescsnapp/cleanup_orphaned_test_resources
The private verify pipeline currently uses Test Kitchen Azure to test against Windows 10. Unfortunately this approach does not clean up after itself and orphaned resource groups are typically left behind. If this is not taken care of we'll exhaust our resource pool (esp. public ips). This commit simply adds a nightly (1am) script to delete the Azure resource groups associated with the private verify pipeline. Signed-off-by: Christopher A. Snapp <csnapp@chef.io>
-rwxr-xr-x.expeditor/cleanup_orphaned_test_resources.sh15
-rw-r--r--.expeditor/config.yml9
2 files changed, 24 insertions, 0 deletions
diff --git a/.expeditor/cleanup_orphaned_test_resources.sh b/.expeditor/cleanup_orphaned_test_resources.sh
new file mode 100755
index 0000000000..ccf1c7473a
--- /dev/null
+++ b/.expeditor/cleanup_orphaned_test_resources.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+echo "--- Setting up Azure credentials"
+export VAULT_UTIL_SECRETS="{\"ARM_TENANT_ID\":{\"account\":\"azure/engineering-dev-test\",\"field\":\"tenant_id\"},\"ARM_CLIENT_ID\":{\"account\":\"azure/engineering-dev-test\",\"field\":\"client_id\"},\"ARM_CLIENT_SECRET\":{\"account\":\"azure/engineering-dev-test\",\"field\":\"client_secret\"}}"
+. <(vault-util fetch-secret-env)
+
+# this allows time for the new service-principal to become available
+sleep 10
+
+az login --service-principal --tenant "$ARM_TENANT_ID" --username "$ARM_CLIENT_ID" --password "$ARM_CLIENT_SECRET"
+
+echo "--- Deleting Azure kitchen-end-to-end-windows-10 resource groups"
+az group list --query "[?starts_with(name, 'kitchen-end-to-end-windows-10-')].name" --output tsv | xargs -n1 -t -I% az group delete -y --no-wait --name "%"
diff --git a/.expeditor/config.yml b/.expeditor/config.yml
index e76830b4b4..7858f9d866 100644
--- a/.expeditor/config.yml
+++ b/.expeditor/config.yml
@@ -69,6 +69,11 @@ github:
- chef-14:
version_constraint: 14*
+schedules:
+ - name: cleanup_orphaned_test_resources
+ description: Cleanup orphaned test resources
+ cronline: "0 1 * * *" # every day at 1am
+
changelog:
rollup_header: Changes not yet released to stable
@@ -96,6 +101,10 @@ merge_actions:
only_if: built_in:bump_version
subscriptions:
+ - workload: schedule_triggered:{{agent_id}}:cleanup_orphaned_test_resources:*
+ actions:
+ - bash:.expeditor/cleanup_orphaned_test_resources.sh
+
# the omnibus/docker/gem chain
- workload: artifact_published:unstable:chef:{{version_constraint}}
actions: