Skip to content

Commit bc032b8

Browse files
committed
add extra one query
Signed-off-by: Ben Ye <[email protected]>
1 parent d0aa4d2 commit bc032b8

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

integration/query_frontend_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ func runQueryFrontendTest(t *testing.T, cfg queryFrontendTestConfig) {
368368
extra++
369369
}
370370

371+
if cfg.remoteReadEnabled {
372+
extra++
373+
}
374+
371375
require.NoError(t, queryFrontend.WaitSumMetrics(e2e.Equals(numUsers*numQueriesPerUser+extra), "cortex_query_frontend_queries_total"))
372376

373377
// The number of received request is greater than the query requests because include

pkg/frontend/transport/handler.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/weaveworks/common/httpgrpc/server"
2323
"google.golang.org/grpc/status"
2424

25-
"github.com/cortexproject/cortex/pkg/ingester/client"
2625
querier_stats "github.com/cortexproject/cortex/pkg/querier/stats"
2726
"github.com/cortexproject/cortex/pkg/querier/tripperware"
2827
"github.com/cortexproject/cortex/pkg/tenant"
@@ -34,9 +33,6 @@ const (
3433
// StatusClientClosedRequest is the status code for when a client request cancellation of an http request
3534
StatusClientClosedRequest = 499
3635
ServiceTimingHeaderName = "Server-Timing"
37-
38-
// Queries are a set of matchers with time ranges - should not get into megabytes
39-
maxRemoteReadQuerySize = 1024 * 1024
4036
)
4137

4238
var (
@@ -143,22 +139,15 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
143139
r.Body = io.NopCloser(io.TeeReader(r.Body, &buf))
144140
// We parse form here so that we can use buf as body, in order to
145141
// prevent https://github.com/cortexproject/cortex/issues/5201.
146-
if strings.Contains(r.URL.Path, "api/v1/read") {
147-
var req client.ReadRequest
148-
if err := util.ParseProtoReader(r.Context(), r.Body, int(r.ContentLength), maxRemoteReadQuerySize, &req, util.RawSnappy); err != nil {
149-
level.Error(util_log.WithContext(r.Context(), f.log)).Log("msg", "failed to parse proto", "err", err.Error())
150-
http.Error(w, err.Error(), http.StatusBadRequest)
151-
return
152-
}
153-
} else {
142+
// Exclude remote read here as we don't have to buffer its body.
143+
if !strings.Contains(r.URL.Path, "api/v1/read") {
154144
if err := r.ParseForm(); err != nil {
155145
writeError(w, err)
156146
return
157147
}
148+
r.Body = io.NopCloser(&buf)
158149
}
159150

160-
r.Body = io.NopCloser(&buf)
161-
162151
startTime := time.Now()
163152
resp, err := f.roundTripper.RoundTrip(r)
164153
queryResponseTime := time.Since(startTime)

0 commit comments

Comments
 (0)