Skip to content

Commit d671562

Browse files
added retry mechanism for client advisor
1 parent ea52fca commit d671562

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

.github/workflows/CAdeploy.yml

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
- name: List KeyVaults and Store in Array
7777
id: list_keyvaults
7878
run: |
79+
7980
set -e
8081
echo "Listing all KeyVaults in the resource group ${RESOURCE_GROUP_NAME}..."
8182
@@ -108,6 +109,7 @@ jobs:
108109
- name: Update PowerBI URL
109110
if: success()
110111
run: |
112+
111113
set -e
112114
113115
COMMON_PART="-app-service"
@@ -144,12 +146,65 @@ jobs:
144146
145147
- name: Wait for resource deletion to complete
146148
run: |
147-
echo "Waiting for resource group deletion to complete..."
148-
sleep 120 # Wait for 2 minutes (120 seconds) to allow deletion to complete
149+
150+
# List of keyvaults
151+
KEYVAULTS="${{ env.KEYVAULTS }}"
152+
153+
# Remove the surrounding square brackets, if they exist
154+
stripped_keyvaults=$(echo "$KEYVAULTS" | sed 's/\[\|\]//g')
155+
156+
# Convert the comma-separated string into an array
157+
IFS=',' read -r -a resources_to_check <<< "$stripped_keyvaults"
158+
159+
# Append new resources to the array
160+
resources_to_check+=("${{ env.SOLUTION_PREFIX }}-openai" "${{ env.SOLUTION_PREFIX }}-cogser")
161+
162+
echo "List of resources to check: ${resources_to_check[@]}"
163+
164+
# Get the list of resources in YAML format
165+
resource_list=$(az resource list --resource-group myResourceGroup4 --output yaml)
166+
167+
# Maximum number of retries
168+
max_retries=3
169+
170+
# Retry intervals in seconds (30, 60, 120)
171+
retry_intervals=(30 60 120)
172+
173+
while true; do
174+
resource_found=false
175+
176+
# Iterate through the resources to check
177+
for resource in "${resources_to_check[@]}"; do
178+
echo "Checking resource: $resource"
179+
if echo "$resource_list" | grep -q "name: $resource"; then
180+
echo "Resource '$resource' exists in the resource group."
181+
resource_found=true
182+
else
183+
echo "Resource '$resource' does not exist in the resource group."
184+
fi
185+
done
186+
187+
# If any resource exists, retry
188+
if [ "$resource_found" = true ]; then
189+
retries=$((retries + 1))
190+
if [ "$retries" -ge "$max_retries" ]; then
191+
echo "Maximum retry attempts reached. Exiting."
192+
break
193+
else
194+
# Wait for the appropriate interval for the current retry
195+
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
196+
sleep ${retry_intervals[$retries-1]}
197+
fi
198+
else
199+
echo "No resources found. Exiting."
200+
break
201+
fi
202+
done
149203
150204
- name: Purging the Resources
151205
if: success()
152206
run: |
207+
153208
set -e
154209
# Define variables
155210
OPENAI_COMMON_PART="-openai"
@@ -205,6 +260,7 @@ jobs:
205260
- name: Send Notification on Failure
206261
if: failure()
207262
run: |
263+
208264
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
209265
210266
# Construct the email body

0 commit comments

Comments
 (0)