Skip to content
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

Closed
ddpolyakov opened this issue Dec 22, 2020 · 2 comments
Closed

unexpected 307 TemporaryRedirect handling behaviour #2708

ddpolyakov opened this issue Dec 22, 2020 · 2 comments
Assignees

Comments

@ddpolyakov
Copy link

ddpolyakov commented Dec 22, 2020

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

@ddpolyakov ddpolyakov added the needs-triage This issue or PR still needs to be triaged. label Dec 22, 2020
@swetashre swetashre self-assigned this Jan 4, 2021
@swetashre
Copy link
Contributor

swetashre commented Jan 5, 2021

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.
Considering its not an AWS service, i don't know how much we would be able to help here.

@swetashre swetashre added closing-soon This issue will automatically close in 4 days unless further comments are made. and removed needs-triage This issue or PR still needs to be triaged. labels Jan 5, 2021
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jan 9, 2021
@github-actions github-actions bot closed this as completed Jan 9, 2021
@ddpolyakov
Copy link
Author

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)
2020-12-22 16:44:33,681 botocore.parsers [DEBUG] Response body:
b'TemporaryRedirectRedirect10.212.0.184:51081/s3new_bucket'

Than we have HEAD request to
HEAD
/s3/new_bucket
host:ais-object-store.pfm:51080

And a response with the headers
[DEBUG] Response headers: {'Server': 'AIS', 'X-Amz-Bucket-Region': 'ais', 'Date': 'Tue, 22 Dec 2020 16:44:33 GMT'}

next request botocore recreates (for some reason) endpoint with the amazon domain
"PUT
/s3/new_bucket/of

content-md5:1B2M2Y8AsgTpgAmY7PhCfg==
host:s3.ais.amazonaws.com"

Is that correct behaviour and I should create an issue to aistore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants