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-04 11:16:12 -0600
commit1234b745a93167d2227c9ab840706377393665e0 (patch)
treeb9ab80b1c599b5b5b610921a749ab9216aac0c72
parentcbf2666da391bde24de60b726d22486545693ae3 (diff)
downloadchef-1234b745a93167d2227c9ab840706377393665e0.tar.gz
Add nightly cleanup of 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: