-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
add validation before creating an s3 bucket for scenario testing #12013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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!
except ClientError as exc: | ||
if exc.response["Error"]["Message"] != "Not Found": | ||
raise exc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
d6529fd
to
4282d60
Compare
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 @alexrashedChanges
Testing