From 8df44d1250b18275f39b5058106f997a22c9a594 Mon Sep 17 00:00:00 2001 From: Andrew Seigner Date: Tue, 7 Dec 2021 18:41:16 +0000 Subject: [PATCH] objstore/azure: Only create an http client once `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 abd540da48..28f46064f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pkg/objstore/azure/helpers.go b/pkg/objstore/azure/helpers.go index ce24564241..0edd448ada 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