Skip to content

Commit

Permalink
Merge pull request thanos-io#66 from Shopify/fix-grpc-timeout
Browse files Browse the repository at this point in the history
Fix gRPC query timeout
  • Loading branch information
fpetkovski committed Feb 6, 2023
2 parents 21b8f03 + 01ce750 commit 456bfa2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/api/query/grpc.go
Expand Up @@ -9,11 +9,12 @@ import (

"github.com/prometheus/prometheus/promql"
v1 "github.com/prometheus/prometheus/web/api/v1"
"google.golang.org/grpc"

"github.com/thanos-io/thanos/pkg/api/query/querypb"
"github.com/thanos-io/thanos/pkg/query"
"github.com/thanos-io/thanos/pkg/store/labelpb"
"github.com/thanos-io/thanos/pkg/store/storepb/prompb"
"google.golang.org/grpc"
)

type GRPCAPI struct {
Expand Down Expand Up @@ -136,7 +137,8 @@ func (g *GRPCAPI) QueryRange(request *querypb.QueryRangeRequest, srv querypb.Que
ctx := srv.Context()
if request.TimeoutSeconds != 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Duration(request.TimeoutSeconds))
timeout := time.Duration(request.TimeoutSeconds) * time.Second
ctx, cancel = context.WithTimeout(ctx, timeout)
defer cancel()
}

Expand Down

0 comments on commit 456bfa2

Please sign in to comment.