Skip to content

Commit

Permalink
objstore/azure: Only create an http client once (#4928)
Browse files Browse the repository at this point in the history
`getContainerURL` was creating a new `http.Client` within `HTTPSender`.
This increased memory pressure on components making requests to Azure.

Move `http.Client` creation out of `HTTPSender`, only creating it once
per call to `getContainerURL`.

Signed-off-by: Andrew Seigner <[email protected]>
  • Loading branch information
siggy authored Dec 7, 2021
1 parent 397fcb1 commit c9d7465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#4792](https://github.com/thanos-io/thanos/pull/4792) Store: Fix data race in BucketedBytes pool.
- [#4769](https://github.com/thanos-io/thanos/pull/4769) Query-frontend+api: add "X-Request-ID" field and other fields to start call log.
- [#4918](https://github.com/thanos-io/thanos/pull/4918) Tracing: Fixing force tracing with Jaeger.
- [#4928](https://github.com/thanos-io/thanos/pull/4928) Azure: Only create an http client once, to conserve memory.

### Changed

Expand Down
8 changes: 4 additions & 4 deletions pkg/objstore/azure/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func getContainerURL(ctx context.Context, logger log.Logger, conf Config) (blob.
retryOptions.TryTimeout = time.Until(deadline)
}

client := http.Client{
Transport: DefaultTransport(conf),
}

p := blob.NewPipeline(credentials, blob.PipelineOptions{
Retry: retryOptions,
Telemetry: blob.TelemetryOptions{Value: "Thanos"},
Expand All @@ -117,10 +121,6 @@ func getContainerURL(ctx context.Context, logger log.Logger, conf Config) (blob.
},
HTTPSender: pipeline.FactoryFunc(func(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.PolicyFunc {
return func(ctx context.Context, request pipeline.Request) (pipeline.Response, error) {
client := http.Client{
Transport: DefaultTransport(conf),
}

resp, err := client.Do(request.WithContext(ctx))

return pipeline.NewHTTPResponse(resp), err
Expand Down

0 comments on commit c9d7465

Please sign in to comment.