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

Adds custom registry User-Agent header to s3 HTTP requests #1381

Merged
merged 1 commit into from
Feb 1, 2016

Conversation

BrianBland
Copy link
Contributor

Uses docker/goamz instead of AdRoll/goamz

Adds a registry UA string param to the storage parameters when
constructing the storage driver for the registry App.
This could be used by other storage drivers as well

Addresses #1353

@BrianBland
Copy link
Contributor Author

Also enables s3 connection pooling as a side-effect

@codecov-io
Copy link

Current coverage is 53.82%

Merging #1381 into master will decrease coverage by -3.43% as of 2dc1af1

@@            master   #1381   diff @@
======================================
  Files          123     123       
  Stmts        11338   11127   -211
  Branches       798     705    -93
  Methods          0       0       
======================================
- Hit           6492    5989   -503
+ Partial        798     705    -93
- Missed        4048    4433   +385

Review entire Coverage Diff as of 2dc1af1


Uncovered Suggestions

  1. +0.29% via ...ge/driver/gcs/gcs.go#182...213
  2. +0.24% via ...ge/driver/gcs/gcs.go#85...111
  3. +0.21% via ...ge/driver/gcs/gcs.go#471...494
  4. See 7 more...

Powered by Codecov. Updated on successful CI builds.

@aaronlehmann
Copy link
Contributor

Connection pooling should be HUGE. It would be great to get some informal benchmarks to see how much this helps.

I know I was cheerleading for a fork, but it looks like AdRoll/goamz is still active. I think we should contribute these changes upstream. If they don't want them, fine. And we still may need to maintain a fork for other reasons. But contributing the improvements is a nice thing to do.

@BrianBland
Copy link
Contributor Author

I was also looking at the AWS-owned client (https://github.com/aws/aws-sdk-go) and it looks like there's tons more active development there than goamz. I could try a rewrite of the s3 driver using aws-sdk-go, which uses a persistent (and pluggable) *http.Client and has much more readable v4 signing code.

@BrianBland
Copy link
Contributor Author

Updated to include docker/goamz#10 for fixed connection pooling

@aaronlehmann
Copy link
Contributor

LGTM

@dmp42 @RichardScothern Should we consider this for Registry 2.3 because of the big performance improvement?

@RichardScothern
Copy link
Contributor

I'm reluctant to. Although the unit tests show a big performance
improvement, I'm not convinced we have tuned MaxIdleConnsPerHost correctly.

Do we know what this is set to in the official go client?

On Fri, Jan 22, 2016 at 2:55 PM, Aaron Lehmann notifications@github.com
wrote:

LGTM

@dmp42 https://github.com/dmp42 @RichardScothern
https://github.com/RichardScothern Should we consider this for Registry
2.3 because of the big performance improvement?


Reply to this email directly or view it on GitHub
#1381 (comment).

@BrianBland
Copy link
Contributor Author

@RichardScothern MaxIdleConnsPerHost does not exist anywhere in aws/aws-sdk-go, and it seems to just be using http.DefaultClient unless you pass your own in.

@stevvooe
Copy link
Collaborator

@RichardScothern @BrianBland We can do another release after 2.3 with the new S3 drivers, once it is warranted (2.4, perhaps). I believe its nice to release with each docker release, but we can always release more often. There are a few other big changes, such as the path fixup that will save on bandwidth (something like 10% of url keys, although not much in reality 😸 ).

@dmp42 dmp42 mentioned this pull request Jan 25, 2016
25 tasks
@BrianBland
Copy link
Contributor Author

@docker/distribution-maintainers can we merge this?

@dmcgowan
Copy link
Collaborator

LGTM

@dmp42
Copy link
Contributor

dmp42 commented Jan 28, 2016

@BrianBland at this point it's a matter of branch and release management.
@RichardScothern what would be the path forward here? Shall we merge this into a feature branch and converge to master after the release?

@RichardScothern
Copy link
Contributor

We can merge to master and I will create a branch for the release

As a matter of interest, this is being tested in a container on prod with interesting results (see Noah for details)

@RichardScothern
Copy link
Contributor

Before we do, are we ok with the user agent string @BrianBland ?

@BrianBland
Copy link
Contributor Author

Good point, I'm going to update it to fmt.Sprintf("docker-distribution/%s %s", version.Version, runtime.Version()) unless someone has a better suggestion

@stevvooe
Copy link
Collaborator

LGTM

@aaronlehmann
Copy link
Contributor

Is the plan to merge this first and then have a seprate PR that introduces an alternative s3 driver using the official SDK (which will probably become the one named "s3")?

@BrianBland
Copy link
Contributor Author

Exactly, #1385 adds the alternative s3 driver and changes the name of this one to s3goamz


if params.UserAgent != "" {
s3obj.Client = &http.Client{
Transport: transport.NewTransport(http.DefaultTransport, transport.NewHeaderRequestModifier(http.Header{http.CanonicalHeaderKey("User-Agent"): []string{params.UserAgent}})),
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor cosmetic point, but I think this would be easier to read if broken over multiple lines, like this:

s3obj.Client = &http.Client{
    Transport: transport.NewTransport(http.DefaultTransport,
        transport.NewHeaderRequestModifier(http.Header{
            http.CanonicalHeaderKey("User-Agent"): []string{params.UserAgent},
        }),
    ),
}

@aaronlehmann
Copy link
Contributor

LGTM

Uses docker/goamz instead of AdRoll/goamz

Adds a registry UA string param to the storage parameters when
constructing the storage driver for the registry App.
This could be used by other storage drivers as well

Signed-off-by: Brian Bland <brian.bland@docker.com>
@BrianBland
Copy link
Contributor Author

Updated for @aaronlehmann's style nit, merging on green CI

aaronlehmann added a commit that referenced this pull request Feb 1, 2016
Adds custom registry User-Agent header to s3 HTTP requests
@aaronlehmann aaronlehmann merged commit 2fc586d into distribution:master Feb 1, 2016
@BrianBland BrianBland deleted the s3CustomUAString branch February 3, 2016 00:05
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Apr 22, 2021
Adds custom registry User-Agent header to s3 HTTP requests
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Jan 19, 2022
Adds custom registry User-Agent header to s3 HTTP requests
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

8 participants