Skip to content

Conversation

pinzon
Copy link
Member

@pinzon pinzon commented Dec 10, 2024

Motivation

As discussed with @dominikschubert @bentsku S3 behaves differently when creating a Bucket in different regions. Being Idempotent when using region us-east-1 and not idempotent in other Regions. This AWS behavior is causing issues with the Multi-region tests. /cc @alexrashed

Changes

  • Check if intended bucket exists before trying to create it for Scenario test assets.

Testing

  • Since the PR adds extra validation. all green checks should be enough.

@pinzon pinzon added the semver: patch Non-breaking changes which can be included in patch releases label Dec 10, 2024
Copy link

github-actions bot commented Dec 10, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 50m 58s ⏱️ - 2m 9s
3 892 tests ±0  3 583 ✅ ±0  309 💤 ±0  0 ❌ ±0 
3 894 runs  ±0  3 583 ✅ ±0  311 💤 ±0  0 ❌ ±0 

Results for commit 4282d60. ± Comparison against base commit 5949987.

♻️ This comment has been updated with latest results.

@pinzon pinzon marked this pull request as ready for review December 10, 2024 20:40
Copy link
Member

@dominikschubert dominikschubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits, otherwise LGTM!

Comment on lines 407 to 409
except ClientError as exc:
if exc.response["Error"]["Message"] != "Not Found":
raise exc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except ClientError as exc:
if exc.response["Error"]["Message"] != "Not Found":
raise exc
except ClientError:
if exc.response["Error"]["Message"] != "Not Found":
raise

Bit of a nit, feel free to ignore. Just a bit cleaner that way since you don't need the reference

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Given the docs on HeadBucket, it might also be a bit cleaner to check the response code (404) instead

If the bucket does not exist or you do not have permission to
access it, the HEAD request returns a generic 400 Bad Request ,
403 Forbidden or 404 Not Found code. A message body is not in-
cluded, so you cannot determine the exception beyond these HTTP
response codes.

Copy link
Contributor

@bentsku bentsku Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to keep the reference to exc to be able to check on the status code or error message of it though! But just calling raise is cleaner 👍

Agreed for the status code, HeadBucket is weird and the error message often can come from the client itself, so it's easier to check it.

Personally, I would have done a call to CreateBucket and then suppressed the exceptions if the bucket already existed, so you only need to do one call, but that works too!

@pinzon pinzon force-pushed the fix-cdk-testing-s3 branch from d6529fd to 4282d60 Compare December 11, 2024 22:51
@pinzon pinzon merged commit 1977871 into master Dec 12, 2024
31 checks passed
@pinzon pinzon deleted the fix-cdk-testing-s3 branch December 12, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants