Skip to content

Commit

Permalink
bjstore/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 <andrew@sig.gy>
  • Loading branch information
siggy authored and squat committed Dec 9, 2021
1 parent 755e5c7 commit 21871e1
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 @@ -48,6 +48,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#4777](https://github.com/thanos-io/thanos/pull/4777) Query: Fix data race in exemplars server.
- [#4811](https://github.com/thanos-io/thanos/pull/4811) Query: Fix data race in metadata, rules, and targets servers.
- [#4795](https://github.com/thanos-io/thanos/pull/4795) Query: Fix deadlock in endpointset.
- [#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 21871e1

Please sign in to comment.