Skip to content

Commit df5e14e

Browse files
authored
remove limiting query rejection to only adhoc queries for ingester. This shouldn't have been included as discussed in PR #6947 (#7000)
Signed-off-by: Erlan Zholdubai uulu <[email protected]>
1 parent 1a07a14 commit df5e14e

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

pkg/ingester/ingester.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ import (
6363
"github.com/cortexproject/cortex/pkg/util/limiter"
6464
logutil "github.com/cortexproject/cortex/pkg/util/log"
6565
util_math "github.com/cortexproject/cortex/pkg/util/math"
66-
"github.com/cortexproject/cortex/pkg/util/requestmeta"
6766
"github.com/cortexproject/cortex/pkg/util/resource"
6867
"github.com/cortexproject/cortex/pkg/util/services"
6968
"github.com/cortexproject/cortex/pkg/util/spanlogger"
@@ -1697,7 +1696,7 @@ func (i *Ingester) QueryExemplars(ctx context.Context, req *client.ExemplarQuery
16971696
}
16981697

16991698
// We will report *this* request in the error too.
1700-
c, err := i.trackInflightQueryRequest(ctx)
1699+
c, err := i.trackInflightQueryRequest()
17011700
if err != nil {
17021701
return nil, err
17031702
}
@@ -1805,7 +1804,7 @@ func (i *Ingester) labelsValuesCommon(ctx context.Context, req *client.LabelValu
18051804
q.Close()
18061805
}
18071806

1808-
c, err := i.trackInflightQueryRequest(ctx)
1807+
c, err := i.trackInflightQueryRequest()
18091808
if err != nil {
18101809
return nil, cleanup, err
18111810
}
@@ -1902,7 +1901,7 @@ func (i *Ingester) labelNamesCommon(ctx context.Context, req *client.LabelNamesR
19021901
q.Close()
19031902
}
19041903

1905-
c, err := i.trackInflightQueryRequest(ctx)
1904+
c, err := i.trackInflightQueryRequest()
19061905
if err != nil {
19071906
return nil, cleanup, err
19081907
}
@@ -2253,7 +2252,7 @@ func (i *Ingester) QueryStream(req *client.QueryRequest, stream client.Ingester_
22532252
return nil
22542253
}
22552254

2256-
func (i *Ingester) trackInflightQueryRequest(ctx context.Context) (func(), error) {
2255+
func (i *Ingester) trackInflightQueryRequest() (func(), error) {
22572256
gl := i.getInstanceLimits()
22582257
if gl != nil && gl.MaxInflightQueryRequests > 0 {
22592258
if i.inflightQueryRequests.Load() >= gl.MaxInflightQueryRequests {
@@ -2263,7 +2262,7 @@ func (i *Ingester) trackInflightQueryRequest(ctx context.Context) (func(), error
22632262

22642263
i.maxInflightQueryRequests.Track(i.inflightQueryRequests.Inc())
22652264

2266-
if i.resourceBasedLimiter != nil && !requestmeta.RequestFromRuler(ctx) {
2265+
if i.resourceBasedLimiter != nil {
22672266
if err := i.resourceBasedLimiter.AcceptNewRequest(); err != nil {
22682267
level.Warn(i.logger).Log("msg", "failed to accept request", "err", err)
22692268
return nil, httpgrpc.Errorf(http.StatusServiceUnavailable, "failed to query: %s", limiter.ErrResourceLimitReachedStr)
@@ -2283,7 +2282,7 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
22832282
}
22842283
defer q.Close()
22852284

2286-
c, err := i.trackInflightQueryRequest(ctx)
2285+
c, err := i.trackInflightQueryRequest()
22872286
if err != nil {
22882287
return 0, 0, 0, 0, err
22892288
}

pkg/ingester/ingester_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import (
6161
"github.com/cortexproject/cortex/pkg/util"
6262
"github.com/cortexproject/cortex/pkg/util/chunkcompat"
6363
"github.com/cortexproject/cortex/pkg/util/limiter"
64-
"github.com/cortexproject/cortex/pkg/util/requestmeta"
6564
"github.com/cortexproject/cortex/pkg/util/resource"
6665
"github.com/cortexproject/cortex/pkg/util/services"
6766
"github.com/cortexproject/cortex/pkg/util/test"
@@ -3228,18 +3227,11 @@ func Test_Ingester_Query_ResourceThresholdBreached(t *testing.T) {
32283227
}
32293228

32303229
rreq := &client.QueryRequest{}
3231-
ctx = requestmeta.ContextWithRequestSource(ctx, requestmeta.SourceAPI)
32323230
s := &mockQueryStreamServer{ctx: ctx}
32333231
err = i.QueryStream(rreq, s)
32343232
require.Error(t, err)
32353233
exhaustedErr := limiter.ResourceLimitReachedError{}
32363234
require.ErrorContains(t, err, exhaustedErr.Error())
3237-
3238-
// we shouldn't reject queries from ruler
3239-
ctx = requestmeta.ContextWithRequestSource(ctx, requestmeta.SourceRuler)
3240-
s = &mockQueryStreamServer{ctx: ctx}
3241-
err = i.QueryStream(rreq, s)
3242-
require.Nil(t, err)
32433235
}
32443236

32453237
func TestIngester_LabelValues_ShouldNotCreateTSDBIfDoesNotExists(t *testing.T) {

0 commit comments

Comments
 (0)