Skip to content

Commit d428777

Browse files
ps3-smoke - retry teardown deletes and warn when resources leak (#10516)
1 parent 2b269da commit d428777

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

.github/workflows/ps3-smoke.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,27 @@ jobs:
4545
# no tr|head pipeline here: with pipefail the SIGPIPE would kill the step
4646
PASS="Db$(openssl rand -hex 10)!5k"
4747
48+
# an NRP transient (NetworkingInternalOperationError) has leaked a VM before,
49+
# and the || true made it invisible: retry each delete, then surface anything
50+
# left behind as a warning annotation instead of failing the smoke verdict
51+
retry() {
52+
for attempt in 1 2 3; do
53+
"$@" && return 0
54+
echo "delete attempt $attempt failed, retrying in 30s: $*"
55+
sleep 30
56+
done
57+
return 1
58+
}
59+
4860
cleanup() {
4961
echo "== cleanup"
50-
az vm delete -g "$RG" -n "$VM" --yes || true
51-
az network nic delete -g "$RG" -n "${VM}VMNic" || true
52-
az network public-ip delete -g "$RG" -n "${VM}PublicIP" || true
62+
retry az vm delete -g "$RG" -n "$VM" --yes || true
63+
retry az network nic delete -g "$RG" -n "${VM}VMNic" || true
64+
retry az network public-ip delete -g "$RG" -n "${VM}PublicIP" || true
65+
leaked=$(az resource list -g "$RG" --query "[?contains(name, '$VM')].name" -o tsv 2>/dev/null | paste -sd, - || true)
66+
if [ -n "$leaked" ]; then
67+
echo "::warning::ps3-smoke cleanup leaked $leaked in $RG -- delete manually"
68+
fi
5369
}
5470
trap cleanup EXIT
5571

0 commit comments

Comments
 (0)