-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
unexpected 307 TemporaryRedirect handling behaviour #2708
Comments
Thank you for your post. In case of s3 redirect, botocore uses the region returned by service to form the new endpoint instead of directly using the endpoint. So here the new endpoint is a s3 endpoint with region set as ais, which is invalid and that's why its failing. |
Thx for your reply. But Im still a bit confused - We have basic request with parameters {'url_path': '/new_bucket/of', 'query_string': {}, 'method': 'PUT', 'headers': {'User-Agent': 'Boto3/1.16.41 Python/3.6.9 Linux/5.4.5-1.el7.elrepo.x86_64 Botocore/1.19.41', 'Content-MD5': '1B2M2Y8AsgTpgAmY7PhCfg==', 'Expect': '100-continue'}, 'body': <s3transfer.utils.ReadFileChunk object at 0x7fe267de83c8>, 'url': 'http://ais-object-store.pfm:51080/s3/new_bucket/of', 'context': {'client_region': 'ais', 'client_config': <botocore.config.Config object at 0x7fe26816ea20>, 'has_streaming_input': True, 'auth_type': None, 'signing': {'bucket': 'new_bucket'}}} - client region is set as "ais" As a reply we had TemporaryRedirect with a new endpoint inside (just like it is described at amazon doc) Than we have HEAD request to And a response with the headers next request botocore recreates (for some reason) endpoint with the amazon domain content-md5:1B2M2Y8AsgTpgAmY7PhCfg== Is that correct behaviour and I should create an issue to aistore? |
Describe the bug
Im using Aistore as an s3 backend - ais-object-store.pfm:51080 endpoint. Im trying to use upload_file client function. And Im having s3.ais.amazonaws.com as a suggested host after redirect from aistore. And boto3 completely ignores new Endpoint suggested in redirect response.
I can suggest that aistore is having correct behaviour with the redirects as it is described here - https://docs.aws.amazon.com/AmazonS3/latest/dev/Redirects.html#TemporaryRedirection
Updating URI from http://ais-object-store.pfm:51080/s3/new_bucket/of to http://s3.ais.amazonaws.com/s3/new_bucket/of
it works well after adding this workaround inside redirect_from_error function of botocore/utils.py
changing this: endpoint = endpoint['endpoint_url']
to:
< ### TO DELETE
< if error and 'Endpoint' in error:
< endpoint = 'http://'+error['Endpoint']
< else:
< endpoint = endpoint['endpoint_url']
Im pretty sure if I would use the download_file / anything else - I will face similar issues
Steps to reproduce
Im using simple upload_file example from here https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html with custom endpoint_url in config
Expected behavior
Im expecting correct update of endpoint after 307 with a new Endpoint inside the message
Debug logs
log
boto.log
in attach
The text was updated successfully, but these errors were encountered: