summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: