diff --git a/.github/scripts/cleanup_cosi_resources.sh b/.github/scripts/cleanup_cosi_resources.sh index a70e493f..9f18984f 100755 --- a/.github/scripts/cleanup_cosi_resources.sh +++ b/.github/scripts/cleanup_cosi_resources.sh @@ -51,8 +51,7 @@ for BUCKET_NAME in $BUCKET_NAMES; do log_and_run kubectl patch bucket "$BUCKET_NAME" -p '{"metadata":{"finalizers":[]}}' --type=merge || { echo "Finalizers not found for bucket: $BUCKET_NAME" | tee -a "$LOG_FILE"; } done -log_and_run echo "Deleting Bucket Access and Bucket Access Class..." -log_and_run kubectl delete -f cosi-examples/bucketaccess.yaml || { echo "No BucketAccess resources found." | tee -a "$LOG_FILE"; } +log_and_run echo "Deleting Bucket Access Class..." log_and_run kubectl delete -f cosi-examples/bucketaccessclass.yaml --all || { echo "No BucketAccessClass resources found." | tee -a "$LOG_FILE"; } log_and_run echo "Deleting Bucket Class and Bucket Claim..." diff --git a/.github/scripts/e2e_tests.sh b/.github/scripts/e2e_tests.sh index 45f5c8d0..1dc46582 100755 --- a/.github/scripts/e2e_tests.sh +++ b/.github/scripts/e2e_tests.sh @@ -212,4 +212,31 @@ if [[ "$ACTUAL_PROTOCOLS" != "$EXPECTED_PROTOCOLS" ]]; then exit 1 fi +# Step 11: Delete Bucket Access Resource +log_and_run echo "Deleting Bucket Access Resource..." +log_and_run kubectl delete -f cosi-examples/bucketaccess.yaml + +# Step 12: Verify IAM User Deletion +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 + +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 +fi + log_and_run echo "All verifications for object-storage-access-secret passed successfully."