Skip to content

Commit

Permalink
Revert "Early Request Validation in Query Frontend (#10093)"
Browse files Browse the repository at this point in the history
This reverts commit 3251e86.
  • Loading branch information
francoposa authored Dec 6, 2024
1 parent 3251e86 commit db47122
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 387 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
* [ENHANCEMENT] Distributor: allow a different limit for info series (series ending in `_info`) label count, via `-validation.max-label-names-per-info-series`. #10028
* [ENHANCEMENT] Ingester: do not reuse labels, samples and histograms slices in the write request if there are more entries than 10x the pre-allocated size. This should help to reduce the in-use memory in case of few requests with a very large number of labels, samples or histograms. #10040
* [ENHANCEMENT] Query-Frontend: prune `<subquery> and on() (vector(x)==y)` style queries and stop pruning `<subquery> < -Inf`. Triggered by https://github.com/prometheus/prometheus/pull/15245. #10026
* [ENHANCEMENT] Query-Frontend: perform request format validation before processing the request. #10093
* [BUGFIX] Fix issue where functions such as `rate()` over native histograms could return incorrect values if a float stale marker was present in the selected range. #9508
* [BUGFIX] Fix issue where negation of native histograms (eg. `-some_native_histogram_series`) did nothing. #9508
* [BUGFIX] Fix issue where `metric might not be a counter, name does not end in _total/_sum/_count/_bucket` annotation would be emitted even if `rate` or `increase` did not have enough samples to compute a result. #9508
Expand Down
35 changes: 0 additions & 35 deletions pkg/frontend/querymiddleware/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package querymiddleware
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"net/http"
Expand All @@ -33,7 +32,6 @@ import (
"golang.org/x/exp/slices"

apierror "github.com/grafana/mimir/pkg/api/error"
"github.com/grafana/mimir/pkg/cardinality"
"github.com/grafana/mimir/pkg/mimirpb"
"github.com/grafana/mimir/pkg/querier/api"
"github.com/grafana/mimir/pkg/querier/stats"
Expand Down Expand Up @@ -584,39 +582,6 @@ func DecodeLabelsSeriesQueryTimeParams(reqValues *url.Values) (start, end int64,
return start, end, err
}

// DecodeCardinalityQueryParams strictly handles validation for cardinality API endpoint parameters.
// The current decoding of the cardinality requests is handled in the cardinality package
// which is not yet compatible with the codec's approach of using interfaces
// and multiple concrete proto implementations to represent different query types.
func DecodeCardinalityQueryParams(r *http.Request) (any, error) {
var err error

reqValues, err := util.ParseRequestFormWithoutConsumingBody(r)
if err != nil {
return nil, apierror.New(apierror.TypeBadData, err.Error())
}

var parsedReq any
switch {
case strings.HasSuffix(r.URL.Path, cardinalityLabelNamesPathSuffix):
parsedReq, err = cardinality.DecodeLabelNamesRequestFromValues(reqValues)

case strings.HasSuffix(r.URL.Path, cardinalityLabelValuesPathSuffix):
parsedReq, err = cardinality.DecodeLabelValuesRequestFromValues(reqValues)

case strings.HasSuffix(r.URL.Path, cardinalityActiveSeriesPathSuffix):
parsedReq, err = cardinality.DecodeActiveSeriesRequestFromValues(reqValues)

default:
return nil, errors.New("unknown cardinality API endpoint")
}

if err != nil {
return nil, apierror.New(apierror.TypeBadData, err.Error())
}
return parsedReq, nil
}

func decodeQueryMinMaxTime(queryExpr parser.Expr, start, end, step int64, lookbackDelta time.Duration) (minTime, maxTime int64) {
evalStmt := &parser.EvalStmt{
Expr: queryExpr,
Expand Down
92 changes: 0 additions & 92 deletions pkg/frontend/querymiddleware/request_validation.go

This file was deleted.

Loading

0 comments on commit db47122

Please sign in to comment.