Skip to content

Commit c046c08

Browse files
siggysquat
authored andcommitted
bjstore/azure: Only create an http client once (#4928)
`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]>
1 parent 755e5c7 commit c046c08

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
4848
- [#4777](https://github.com/thanos-io/thanos/pull/4777) Query: Fix data race in exemplars server.
4949
- [#4811](https://github.com/thanos-io/thanos/pull/4811) Query: Fix data race in metadata, rules, and targets servers.
5050
- [#4795](https://github.com/thanos-io/thanos/pull/4795) Query: Fix deadlock in endpointset.
51+
- [#4928](https://github.com/thanos-io/thanos/pull/4928) Azure: Only create an http client once, to conserve memory.
5152

5253
### Changed
5354

pkg/objstore/azure/helpers.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ func getContainerURL(ctx context.Context, logger log.Logger, conf Config) (blob.
104104
retryOptions.TryTimeout = time.Until(deadline)
105105
}
106106

107+
client := http.Client{
108+
Transport: DefaultTransport(conf),
109+
}
110+
107111
p := blob.NewPipeline(credentials, blob.PipelineOptions{
108112
Retry: retryOptions,
109113
Telemetry: blob.TelemetryOptions{Value: "Thanos"},
@@ -117,10 +121,6 @@ func getContainerURL(ctx context.Context, logger log.Logger, conf Config) (blob.
117121
},
118122
HTTPSender: pipeline.FactoryFunc(func(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.PolicyFunc {
119123
return func(ctx context.Context, request pipeline.Request) (pipeline.Response, error) {
120-
client := http.Client{
121-
Transport: DefaultTransport(conf),
122-
}
123-
124124
resp, err := client.Do(request.WithContext(ctx))
125125

126126
return pipeline.NewHTTPResponse(resp), err

0 commit comments

Comments
 (0)