Skip to content

Commit

Permalink
query rejection
Browse files Browse the repository at this point in the history
     small fixes.

Signed-off-by: Erlan Zholdubai uulu <erlanz@amazon.com>
  • Loading branch information
erlan-z committed Jun 14, 2024
1 parent c1a66a9 commit d988c2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 9 additions & 9 deletions pkg/querier/tripperware/query_attribute_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/cortexproject/cortex/pkg/util/validation"
)

const queryRejectErrorMessage = "Query was rejected by operator. Please contact the support for further questions"
const queryRejectErrorMessage = "This query has been rejected by the service operator. Please contact customer support for more information."

func rejectQueryOrSetPriority(r *http.Request, now time.Time, lookbackDelta time.Duration, limits Limits, userStr string, rejectedQueriesPerTenant *prometheus.CounterVec) error {
if limits == nil || !(limits.QueryPriority(userStr).Enabled || limits.QueryRejection(userStr).Enabled) {
Expand Down Expand Up @@ -162,14 +162,14 @@ func isWithinQueryStepLimit(queryStepLimit validation.QueryStepLimit, r *http.Re
}

step, err := util.ParseDurationMs(r.FormValue("step"))
if err == nil {
if queryStepLimit.Min != 0 && time.Duration(queryStepLimit.Min).Milliseconds() > step {
return false
}

if queryStepLimit.Max != 0 && time.Duration(queryStepLimit.Max).Milliseconds() < step {
return false
}
if err != nil {
return false
}
if queryStepLimit.Min != 0 && time.Duration(queryStepLimit.Min).Milliseconds() > step {
return false
}
if queryStepLimit.Max != 0 && time.Duration(queryStepLimit.Max).Milliseconds() < step {
return false
}

var subQueryStep time.Duration
Expand Down
3 changes: 1 addition & 2 deletions pkg/querier/tripperware/query_attribute_matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,10 @@ func Test_isWithinQueryStepLimit(t *testing.T) {
step: "15s",
expectedResult: true,
},
"query should be considered within the step limit if query doesn't have steps": {
"query should be considered outside of the step limit if query doesn't have steps": {
queryString: "count(sum(up))",
step: "not_parseable",
queryStepLimit: queryStepLimit,
expectedResult: true,
},
"should match if step limit set and step is within the range": {
step: "15s",
Expand Down

0 comments on commit d988c2b

Please sign in to comment.