fix(cleanup): detect 503/502 errors as failures and retry

This commit is contained in:
russell@unturf.com 2026-01-29 13:53:53 -05:00
parent 8cf3276f77
commit 70bfb536bc

View file

@ -80,10 +80,12 @@ parallel_destroy() {
# Capture failures by writing failed IDs to a temp file
FAIL_FILE=$(mktemp)
echo "$IDS" | xargs -P "$PARALLEL_JOBS" -I {} sh -c "
if $UN_CLI $resource_type $destroy_cmd '{}' >/dev/null 2>&1; then
OUTPUT=\$($UN_CLI $resource_type $destroy_cmd '{}' 2>&1)
if [ \$? -eq 0 ] && ! echo \"\$OUTPUT\" | grep -qiE 'HTTP [45][0-9][0-9]|error|unavailable|failed'; then
echo 'Destroyed: {}'
else
echo '{}' >> '$FAIL_FILE'
echo 'Failed: {} -' \$(echo \"\$OUTPUT\" | head -1)
fi
"