fix error handling in job to remove orphaned AKS clusters, update README

This commit is contained in:
Ryan Richard
2025-01-03 14:53:35 -08:00
parent 26ccd824a4
commit 8e6ecb9466
2 changed files with 11 additions and 4 deletions
+3 -2
View File
@@ -155,8 +155,9 @@ This requires the following:
Create the app in "My Organization Only". It does not need a redirect URI or any other optional settings.
Create a client secret for this app. If you want the client secret to have a long lifetime, you can use the `az` CLI to create it.
In the Subscription's IAM settings, assign this app the role "Azure Kubernetes Service Contributor Role" to allow
the app to manage AKS clusters. Do not grant this app permissions in any other Subscription or use it for any
other purpose.
the app to manage AKS clusters. Also assign this app the role "Reader" to allow it to read all resources
(used by the `remove-orphaned-aks-clusters` CI task).
Do not grant this app permissions in any other Subscription or use it for any other purpose.
3. Configure the pipelines with the app's Application (client) ID, Client Secret, and Directory (tenant) ID
as the appropriate secret values.
@@ -44,9 +44,15 @@ cat all-clusters.txt
echo
# Remove clusters with unexpected name formats. They might have been created manually for testing.
cat all-clusters.txt | grep -E '^aks-[a-f0-9]+ ' >ci-clusters.txt
# The curly braces and "or true" syntax prevents errors when the grep fails to find any matches.
cat all-clusters.txt | { grep -E '^aks-[a-f0-9]+ ' || true; } >ci-clusters.txt
echo "Only those clusters with expected naming convention:"
if [[ ! -s ci-clusters.txt ]]; then
echo "No clusters matching the expected naming convention were found."
exit 0
fi
echo "Only those clusters matched the expected naming convention:"
cat ci-clusters.txt
echo