Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query-frontend: remove duplicate defaulting of instant query time param #7026

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions pkg/frontend/querymiddleware/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"flag"
"fmt"
"net/http"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -314,9 +313,7 @@ func newQueryTripperware(

return func(next http.RoundTripper) http.RoundTripper {
queryrange := newLimitedParallelismRoundTripper(next, codec, limits, queryRangeMiddleware...)
instant := defaultInstantQueryParamsRoundTripper(
newLimitedParallelismRoundTripper(next, codec, limits, queryInstantMiddleware...),
)
instant := newLimitedParallelismRoundTripper(next, codec, limits, queryInstantMiddleware...)

// Wrap next for cardinality, labels queries and all other queries.
// That attempts to parse "start" and "end" from the HTTP request and set them in the request's QueryDetails.
Expand Down Expand Up @@ -418,22 +415,3 @@ func IsCardinalityQuery(path string) bool {
func IsLabelsQuery(path string) bool {
return strings.HasSuffix(path, labelNamesPathSuffix) || labelValuesPathSuffix.MatchString(path)
}

func defaultInstantQueryParamsRoundTripper(next http.RoundTripper) http.RoundTripper {
return RoundTripFunc(func(r *http.Request) (*http.Response, error) {
if IsInstantQuery(r.URL.Path) && !r.Form.Has("time") && !r.URL.Query().Has("time") {
nowUnixStr := strconv.FormatInt(time.Now().Unix(), 10)

q := r.URL.Query()
q.Add("time", nowUnixStr)
r.URL.RawQuery = q.Encode()

// If form was already parsed, add this param to the form too.
// (The form doesn't have "time", otherwise we'd not be here)
if r.Form != nil {
r.Form.Set("time", nowUnixStr)
}
}
return next.RoundTrip(r)
})
}
Loading