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

set region from s3 endpoint if present #2234

Merged
merged 1 commit into from Aug 4, 2017
Merged

Conversation

poornas
Copy link
Contributor

@poornas poornas commented Aug 3, 2017

Fixes #2224

Currently list bucket fails on mc if the endpoint entered in mc config has a region specific endpoint such as s3.eu-west-1.amazonaws.com. This PR parses the region from endpoint and instantiates the client with region if specified.

@codecov-io
Copy link

codecov-io commented Aug 3, 2017

Codecov Report

Merging #2234 into master will increase coverage by 0.06%.
The diff coverage is 54.54%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2234      +/-   ##
=========================================
+ Coverage    8.87%   8.94%   +0.06%     
=========================================
  Files          93      93              
  Lines        9033    9048      +15     
=========================================
+ Hits          802     809       +7     
- Misses       8104    8110       +6     
- Partials      127     129       +2
Impacted Files Coverage Δ
cmd/client-s3.go 14.76% <54.54%> (+0.4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b62fa40...786302c. Read the comment docs.

cmd/client-s3.go Outdated
// getRegionFromHost - parse region from host name if present.
func getRegionFromHost(host string) (region string) {
region = ""
if isGoogle(host) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use s3utils.IsGoogleCloudEndpoint() - perhaps combine below if and Google in a switch case and return?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

cmd/mb-main.go Outdated
@@ -29,7 +29,7 @@ var (
mbFlags = []cli.Flag{
cli.StringFlag{
Name: "region",
Value: "us-east-1",
Value: "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave this as is.. since we don't expect users to set this value.. if its empty its used as us-east-1 in MakeBucket(). Keeping it explicit serves as a way to document..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using empty string deliberately here - minio-go overrides region specified in client constructor only if location string is empty. If mb call passes us-east-1 as region, all mc mb calls without region will fail with header mismatch and confusing error message that the location should not be us-east-1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshavardhana, overriding region inside client-s3 so that default is not changed

cmd/mb-main.go Outdated
@@ -124,7 +122,11 @@ func mainMakeBucket(ctx *cli.Context) error {
cErr = exitStatus(globalErrorExitStatus)
continue
}

// Save region.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can be better.. save region doesn't mean anything here.

@poornas poornas force-pushed the issue/2224 branch 2 times, most recently from e53aa04 to bcb68bb Compare August 4, 2017 02:24
Copy link
Collaborator

@ebozduman ebozduman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deekoder deekoder merged commit 1e81c03 into minio:master Aug 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants