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

config: default S3v2 for google endpoints #2179

Merged
merged 2 commits into from
Jun 13, 2017
Merged

config: default S3v2 for google endpoints #2179

merged 2 commits into from
Jun 13, 2017

Conversation

CarterMcClellan
Copy link
Contributor

@CarterMcClellan CarterMcClellan commented Jun 9, 2017

config: Force S3v2 for google endpoints

@@ -128,6 +128,9 @@ func mainConfigHostAdd(ctx *cli.Context) error {
api := args.Get(4)
if api == "" {
api = "S3v4"
if url == "https://storage.googleapis.com" {
Copy link
Member

Choose a reason for hiding this comment

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

We have to do this little elaborate check to cater for these conditions.

  • URL is storage.googleapis.com and then no signature type was specified default to s3v2 which this patch addresses.
  • URL is storage.googleapis.com and then signature type was specified by it was specified wrong as s3v4 where we need to error out indicating that user should use s3v2 instead in the error message.

To check if the url is google we should just use the helper

if isGoogle(url) {
    api = "S3v2"
}

@codecov-io
Copy link

codecov-io commented Jun 9, 2017

Codecov Report

Merging #2179 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2179      +/-   ##
=========================================
- Coverage    9.15%   9.15%   -0.01%     
=========================================
  Files          93      93              
  Lines        6901    6906       +5     
=========================================
  Hits          632     632              
- Misses       6135    6140       +5     
  Partials      134     134
Impacted Files Coverage Δ
cmd/config-host-add.go 0% <0%> (ø) ⬆️

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 800f0af...be85f49. Read the comment docs.

@deekoder deekoder requested a review from vadmeste June 12, 2017 18:39
cmd/client-s3.go Outdated
@@ -940,7 +940,11 @@ func isAmazonAccelerated(host string) bool {
}

func isGoogle(host string) bool {
return s3utils.IsGoogleEndpoint(url.URL{Host: host})
url, err := url.Parse(host)
Copy link
Member

Choose a reason for hiding this comment

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

@CarterMcClellan thanks for this PR.

isGoogle() is used to receive only a host address without scheme and path.

Now the problem is that, if we go with this change and then move to go 1.8, we will have the following (unexpected, I know) result:

isGoogle("storage.googleapis.com") = false

That's because with go 1.8, url.Parse("storage.googleapis.com") returns url.Host = "" and url.Path = "storage.googleapis.com"

So I really suggest moving url.Parse() code in config-host-add.go with the change that you already did.

@@ -126,6 +128,16 @@ func mainConfigHostAdd(ctx *cli.Context) error {
accessKey := args.Get(2)
secretKey := args.Get(3)
api := args.Get(4)

urlHost, _ := urlpkg.Parse(url)
Copy link
Member

Choose a reason for hiding this comment

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

Could you rename urlHost to parsedURL ? that would be more meaningful.


if isGoogle(urlHost.Host) {
if api == "S3v4" {
fatalIf(errInvalidArgument().Trace(api), "Unsupported API signature for url. Please use `mc config host add "+alias+" "+url+" "+accessKey+" "+secretKey+" S3v2` instead")
Copy link
Member

Choose a reason for hiding this comment

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

A missing dot at the end of the error message.

@vadmeste
Copy link
Member

vadmeste commented Jun 13, 2017

One final comment is, can you reword your commit message like:

config: Force S3v2 for google endpoints

@harshavardhana harshavardhana changed the title fixed issue #2174, set default api for all urls containing 'https://s… config: default S3v2 for google endpoints Jun 13, 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.

4 participants