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

Region setting not working #262

Closed
kemege opened this issue Dec 19, 2020 · 5 comments · Fixed by #270
Closed

Region setting not working #262

kemege opened this issue Dec 19, 2020 · 5 comments · Fixed by #270
Assignees
Labels
non-aws Issue related to other S3-Compatible Services
Milestone

Comments

@kemege
Copy link
Contributor

kemege commented Dec 19, 2020

I'm currently using s5cmd to backup files to CTClouds (It provides S3-compitable storage, running by China Telecom).
The s5cmd binary I'm using is compiled locally using go get.

I'm copying files to a bucket on region "sh2", and this information is specified in ~/.aws/config. However, when uploading, s5cmd always tries to upload to us-east-1, thus causing a AuthorizationHeaderMalformed error. Setting env AWS_REGION or AWS_DEFAULT_REGION to "sh2" won't change anything.

I noticed that since 1.2.0, s5cmd includes a feature "automatically determines region information of destination buckets". I'm wondering if it has anything to do with this feature, or is there any way I can confirm that, since adding --log debug won't give me any additional information.

@kemege kemege changed the title Region setting not working for CTClouds Region setting not working Dec 19, 2020
@igungor
Copy link
Member

igungor commented Dec 31, 2020

Hi @kemege

Have you tried with v1.1.0? Has this worked before?

@kemege
Copy link
Contributor Author

kemege commented Jan 4, 2021

Yes, s5cmd worked well before. I tried v1.1.0 on the same machine and files are uploaded successfully.
On another machine I am using a binary compiled with go get at Sep. 26, 2020 (between the release of v1.1.0 and v1.2.0), and everything looks fine.

I guess the reason why s5 cp fails might be in the implementation of CTClouds (since other people don't have similar problems), but I wonder if there's any way (stderr, log files, etc.) I can confirm it.
Besides, setting AWS_REGION or AWS_DEFAULT_REGION should override the region inferred by s5cmd, but this does not seem to happen.

@Contextualist
Copy link

I'm experiencing the same issue working with Scaleway's endpoint. v1.2.1 does not respect the AWS_REGION or AWS_DEFAULT_REGION settings, but v1.1.0 does.

@kemege
Copy link
Contributor Author

kemege commented Jan 12, 2021

I'm not familiar with the code of s5cmd, but after some searching, I think this issue might be caused by the removal of the region setting here:
2dad7e1#diff-22a91901acea81cf09b58954babe267e1a5b503dbce7c37ab0df11ebfc86b0b1L649

But I'm not sure whether adding this back will solve this issue or break the functionality of cross-region transfer support.

@kemege
Copy link
Contributor Author

kemege commented Jan 18, 2021

It turns out that the problem is caused by the behavior of S3 service provider.
Some S3-compatible storages do not set X-Amz-Bucket-Region header in HeadBucketRequest, so s3manager.GetBucketRegionWithClient gets an empty string. Then it's further normalized by s3.NormalizeBucketLocation and become us-east-1.

The normalization happened within s3manager.GetBucketRegionWithClient, so it might be easy to make some changes for personal use, but a general solution might not be easy to implement.

@ilkinulas ilkinulas added this to the v1.4.0 milestone Jun 30, 2021
igungor pushed a commit that referenced this issue Jul 7, 2021
@boraberke boraberke added the non-aws Issue related to other S3-Compatible Services label Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-aws Issue related to other S3-Compatible Services
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants