Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions pkg/querier/queryrange/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func LimitsMiddleware(l Limits) Middleware {
func (l limits) Do(ctx context.Context, r Request) (Response, error) {
userid, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, err
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error())
}

maxQueryLen := l.MaxQueryLength(userid)
Expand All @@ -58,7 +58,7 @@ type RequestResponse struct {
func DoRequests(ctx context.Context, downstream Handler, reqs []Request, limits Limits) ([]RequestResponse, error) {
userid, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, err
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error())
}

// If one of the requests fail, we want to be able to cancel the rest of them.
Expand Down
4 changes: 2 additions & 2 deletions pkg/querier/queryrange/query_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (prometheusCodec) DecodeRequest(_ context.Context, r *http.Request) (Reques
func (prometheusCodec) EncodeRequest(ctx context.Context, r Request) (*http.Request, error) {
promReq, ok := r.(*PrometheusRequest)
if !ok {
return nil, httpgrpc.Errorf(http.StatusInternalServerError, "invalid request format")
return nil, httpgrpc.Errorf(http.StatusBadRequest, "invalid request format")
}
params := url.Values{
"start": []string{encodeTime(promReq.Start)},
Expand Down Expand Up @@ -242,7 +242,7 @@ func (prometheusCodec) EncodeResponse(ctx context.Context, res Response) (*http.

b, err := json.Marshal(a)
if err != nil {
return nil, err
return nil, httpgrpc.Errorf(http.StatusInternalServerError, "error encoding response: %v", err)
}

sp.LogFields(otlog.Int("bytes", len(b)))
Expand Down
4 changes: 3 additions & 1 deletion pkg/querier/queryrange/results_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
"net/http"
"sort"
"time"

Expand All @@ -15,6 +16,7 @@ import (
otlog "github.com/opentracing/opentracing-go/log"
"github.com/prometheus/common/model"
"github.com/uber/jaeger-client-go"
"github.com/weaveworks/common/httpgrpc"
"github.com/weaveworks/common/user"

"github.com/cortexproject/cortex/pkg/chunk/cache"
Expand Down Expand Up @@ -133,7 +135,7 @@ func NewResultsCacheMiddleware(
func (s resultsCache) Do(ctx context.Context, r Request) (Response, error) {
userID, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, err
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error())
}

var (
Expand Down
14 changes: 8 additions & 6 deletions pkg/querier/queryrange/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (
"github.com/weaveworks/common/httpgrpc"
)

var retries = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: "cortex",
Name: "query_frontend_retries",
Help: "Number of times a request is retried.",
Buckets: []float64{0, 1, 2, 3, 4, 5},
})
var (
retries = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: "cortex",
Name: "query_frontend_retries",
Help: "Number of times a request is retried.",
Buckets: []float64{0, 1, 2, 3, 4, 5},
})
)

type retry struct {
log log.Logger
Expand Down
3 changes: 2 additions & 1 deletion pkg/querier/queryrange/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/weaveworks/common/httpgrpc"
"github.com/weaveworks/common/user"

"github.com/cortexproject/cortex/pkg/chunk/cache"
Expand Down Expand Up @@ -182,7 +183,7 @@ func (q roundTripper) Do(ctx context.Context, r Request) (Response, error) {
}

if err := user.InjectOrgIDIntoHTTPRequest(ctx, request); err != nil {
return nil, err
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error())
}

response, err := q.next.RoundTrip(request)
Expand Down