Retry list requests for InvalidRegion
error responses
#1074
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
S3 responds with
AuthorizationHeaderMalformed
|InvalidRegion
for the requests which have wrong region set. minio-go already retries such requests with the correct region set in the errResponse.Region.The retry code was buggy which will not do if the bucketName is empty. Few list requests will not have bucketName set. So this fix covers all of it.
To Test:
1 - Vendorize this patch in minio/mc to test the fix
2 - [Hack] Configure mc to use
mc config host add s3-west-2-ip http://52.218.204.152 <Access-Key> <Secret-Key>
with52.218.204.152
being the ip fors3.us-west-2.amazonaws.com
3 - Create a bucket under that region
mc mb -region us-west-2 s3-west-2-ip/bucketfive
4 - All the
ls
requests uses the defaultus-east-1
. Which will throwAuthorizationHeaderMalformed
in our case since our bucket is inus-west-2
region. Now, if we domc --debug ls s3-west-2-ip/
we can see the request being retried with the correct region provided in the errResp.Region.