Skip to content

Commit

Permalink
[fixup 4] add retry and max attempts to user check
Browse files Browse the repository at this point in the history
  • Loading branch information
anurag4DSB committed Dec 13, 2024
1 parent dfb232c commit 13941ba
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions .github/scripts/e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,12 @@ log_and_run kubectl delete -f cosi-examples/bucketaccess.yaml
log_and_run echo "Verifying IAM user '$IAM_USER_NAME' deletion..."
log_and_run aws --endpoint-url "$IAM_ENDPOINT" iam get-user --user-name "$IAM_USER_NAME"

# Retry logic for checking user deletion
USER_EXISTS="$(aws --endpoint-url "$IAM_ENDPOINT" iam get-user --user-name "$IAM_USER_NAME" --retry-mode standard --max-attempts 12 --delay $DELAY 2>&1 || true)"

for ((i=1; i<=$ATTEMPTS; i++)); do
USER_EXISTS="$(aws --endpoint-url "$IAM_ENDPOINT" iam get-user --user-name "$IAM_USER_NAME" 2>&1 || true)"

if [[ "$USER_EXISTS" == *"NoSuchEntity"* ]]; then
log_and_run echo "IAM user '$IAM_USER_NAME' successfully deleted."
break
else
log_and_run echo "Attempt $i: IAM user '$IAM_USER_NAME' still exists. Retrying in $DELETE_DELAY seconds..."
sleep $DELAY
fi
done

if [[ "$USER_EXISTS" != *"NoSuchEntity"* ]]; then
log_and_run echo "IAM user '$IAM_USER_NAME' was not deleted."
exit 1
if [[ "$USER_EXISTS" == *"NoSuchEntity"* ]]; then
log_and_run echo "IAM user '$IAM_USER_NAME' successfully deleted."
else
log_and_run echo "IAM user '$IAM_USER_NAME' still exists after retries."
fi

# Step 13: Test deletion bucket with deletion policy set
Expand Down

0 comments on commit 13941ba

Please sign in to comment.