From e4bb545c65395c08b6e448a5932846090a607bab Mon Sep 17 00:00:00 2001 From: Andrew Seigner Date: Tue, 7 Dec 2021 11:41:03 -0800 Subject: [PATCH] objstore/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 --- CHANGELOG.md | 1 + pkg/objstore/azure/helpers.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 896cc8d89dd..bb7992ba3e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,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 diff --git a/pkg/objstore/azure/helpers.go b/pkg/objstore/azure/helpers.go index ce245642414..0edd448adac 100644 --- a/pkg/objstore/azure/helpers.go +++ b/pkg/objstore/azure/helpers.go @@ -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"}, @@ -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