From 4568b7bca74faf21b2717f4c71180fd6eba2681b Mon Sep 17 00:00:00 2001 From: Kaviraj Date: Fri, 3 May 2024 12:10:48 +0200 Subject: [PATCH] fix: `code` not initialized in downstream roundtripper Looks like part of this PR introduced this bug. Above patch, converted QueryFrontend tripperware into middleware but failed to pass the right `codec` to downstream roundtripper. This PR passes the codec during `InitFrontend` Signed-off-by: Kaviraj --- pkg/lokifrontend/frontend/config.go | 2 +- pkg/lokifrontend/frontend/downstream_roundtripper.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/lokifrontend/frontend/config.go b/pkg/lokifrontend/frontend/config.go index fb61a482563f..88af13bb539b 100644 --- a/pkg/lokifrontend/frontend/config.go +++ b/pkg/lokifrontend/frontend/config.go @@ -43,7 +43,7 @@ func InitFrontend(cfg CombinedFrontendConfig, ring ring.ReadRing, limits v1.Limi switch { case cfg.DownstreamURL != "": // If the user has specified a downstream Prometheus, then we should use that. - rt, err := NewDownstreamRoundTripper(cfg.DownstreamURL, http.DefaultTransport) + rt, err := NewDownstreamRoundTripper(cfg.DownstreamURL, http.DefaultTransport, codec) return rt, nil, nil, err case cfg.FrontendV2.SchedulerAddress != "" || ring != nil: // If query-scheduler address is configured, use Frontend. diff --git a/pkg/lokifrontend/frontend/downstream_roundtripper.go b/pkg/lokifrontend/frontend/downstream_roundtripper.go index 86010e127621..9cbd066c3704 100644 --- a/pkg/lokifrontend/frontend/downstream_roundtripper.go +++ b/pkg/lokifrontend/frontend/downstream_roundtripper.go @@ -20,13 +20,13 @@ type downstreamRoundTripper struct { codec queryrangebase.Codec } -func NewDownstreamRoundTripper(downstreamURL string, transport http.RoundTripper) (queryrangebase.Handler, error) { +func NewDownstreamRoundTripper(downstreamURL string, transport http.RoundTripper, codec queryrangebase.Codec) (queryrangebase.Handler, error) { u, err := url.Parse(downstreamURL) if err != nil { return nil, err } - return &downstreamRoundTripper{downstreamURL: u, transport: transport}, nil + return &downstreamRoundTripper{downstreamURL: u, transport: transport, codec: codec}, nil } func (d downstreamRoundTripper) Do(ctx context.Context, req queryrangebase.Request) (queryrangebase.Response, error) {