github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/build/teamcity-reset-nightlies.sh (about) 1 #!/usr/bin/env bash 2 3 # Deletes and recreates the nightlies resource group, which contains the Azure 4 # VMs, virtual networks, IPs, disks etc. that are automatically created by 5 # nightly tests. This is a big hammer, but the nightlies leak resources 6 # constantly as `terraform destroy` is not particularly reliable. 7 8 set -euo pipefail 9 10 docker run --rm --interactive \ 11 --env=ARM_CLIENT_ID \ 12 --env=ARM_CLIENT_SECRET \ 13 --env=ARM_TENANT_ID \ 14 --env=ARM_SUBSCRIPTION_ID \ 15 azuresdk/azure-cli-python:2.0.17 bash <<'EOF' 16 set -euo pipefail 17 18 resource_group=cockroach-nightly 19 20 declare -A storage_accounts=( 21 [cockroachnightlyeastvhd]=eastus 22 [cockroachnightlywestvhd]=westus 23 ) 24 25 az login --service-principal --username="$ARM_CLIENT_ID" --password="$ARM_CLIENT_SECRET" --tenant="$ARM_TENANT_ID" 26 az account set --subscription="$ARM_SUBSCRIPTION_ID" 27 28 # Simulate delete-if-exists behavior. 29 az group delete --yes --no-wait --name="$resource_group" || true 30 az group wait --deleted --timeout=$((60 * 10)) --name="$resource_group" 31 32 az group create --location=eastus --name="$resource_group" 33 34 for account_name in "${!storage_accounts[@]}" 35 do 36 location="${storage_accounts[$account_name]}" 37 az storage account create --resource-group="$resource_group" --name="$account_name" --location="$location" --sku=Standard_LRS 38 az storage container create --account-name="$account_name" --name=vhds 39 done 40 EOF