Skip to content

Commit

Permalink
Update dskit and grpc-go to 1.59.0. (#6301)
Browse files Browse the repository at this point in the history
* Update dskit, fix grpc push check.

Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
  • Loading branch information
pstibrany committed Oct 23, 2023
1 parent 5f38c1e commit 790c6ee
Show file tree
Hide file tree
Showing 31 changed files with 358 additions and 305 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/golang/snappy v0.0.4
github.com/google/gopacket v1.1.19
github.com/gorilla/mux v1.8.0
github.com/grafana/dskit v0.0.0-20231021095337-736bca5d13d8
github.com/grafana/dskit v0.0.0-20231023092801-7982d8ce862f
github.com/grafana/e2e v0.1.1
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/json-iterator/go v1.1.12
Expand All @@ -47,7 +47,7 @@ require (
golang.org/x/net v0.17.0
golang.org/x/sync v0.4.0
golang.org/x/time v0.3.0
google.golang.org/grpc v1.58.3
google.golang.org/grpc v1.59.0
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -91,6 +91,7 @@ require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/go-test/deep v1.1.0 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
Expand Down Expand Up @@ -156,7 +157,6 @@ require (
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/golang/glog v1.1.1 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJ
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.1.1 h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw=
github.com/golang/glog v1.1.1/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -536,8 +536,8 @@ github.com/gosimple/slug v1.1.1 h1:fRu/digW+NMwBIP+RmviTK97Ho/bEj/C9swrCspN3D4=
github.com/gosimple/slug v1.1.1/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0=
github.com/grafana-tools/sdk v0.0.0-20220919052116-6562121319fc h1:PXZQA2WCxe85Tnn+WEvr8fDpfwibmEPgfgFEaC87G24=
github.com/grafana-tools/sdk v0.0.0-20220919052116-6562121319fc/go.mod h1:AHHlOEv1+GGQ3ktHMlhuTUwo3zljV3QJbC0+8o2kn+4=
github.com/grafana/dskit v0.0.0-20231021095337-736bca5d13d8 h1:Kyu05lVxS/yyZDjLoGa/O/HovpakRjVRH1jZyoU3+T0=
github.com/grafana/dskit v0.0.0-20231021095337-736bca5d13d8/go.mod h1:byPCvaG/pqi33Kq+Wvkp7WhLfmrlyy0RAoYG4yRh01I=
github.com/grafana/dskit v0.0.0-20231023092801-7982d8ce862f h1:JU9wnGJ9eEsYEra95N57jLgZQIeXFSS6CLj0O+SS9L4=
github.com/grafana/dskit v0.0.0-20231023092801-7982d8ce862f/go.mod h1:ost4aYsWskHY86vgL5UyD4YKn7DREP+1ICYJowzAsUw=
github.com/grafana/e2e v0.1.1 h1:/b6xcv5BtoBnx8cZnCiey9DbjEc8z7gXHO5edoeRYxc=
github.com/grafana/e2e v0.1.1/go.mod h1:RpNLgae5VT+BUHvPE+/zSypmOXKwEu4t+tnEMS1ATaE=
github.com/grafana/goautoneg v0.0.0-20231010094147-47ce5e72a9ae h1:Yxbw9jKGJVC6qAK5Ubzzb/qZwM6rRMMqaDc/d4Vp3pM=
Expand Down Expand Up @@ -1542,8 +1542,8 @@ google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ5
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
28 changes: 20 additions & 8 deletions pkg/mimir/grpc_push_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
package mimir

import (
"context"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)

Expand All @@ -22,27 +25,36 @@ type grpcInflightMethodLimiter struct {
getIngester func() pushReceiver
}

const ingesterPushMethod = "/cortex.Ingester/Push"
type ctxKey int

const (
ingesterPushStarted ctxKey = 1

ingesterPushMethod string = "/cortex.Ingester/Push"
)

var errNoIngester = status.Error(codes.Unavailable, "no ingester")

func (g *grpcInflightMethodLimiter) RPCCallStarting(methodName string) error {
func (g *grpcInflightMethodLimiter) RPCCallStarting(ctx context.Context, methodName string, _ metadata.MD) (context.Context, error) {
if methodName == ingesterPushMethod {
ing := g.getIngester()
if ing == nil {
// We return error here, to make sure that RPCCallFinished doesn't get called for this RPC call.
return errNoIngester
return ctx, errNoIngester
}

if err := ing.StartPushRequest(); err != nil {
return status.Error(codes.Unavailable, err.Error())
err := ing.StartPushRequest()
if err != nil {
return ctx, status.Error(codes.Unavailable, err.Error())
}

return context.WithValue(ctx, ingesterPushStarted, true), nil
}
return nil
return ctx, nil
}

func (g *grpcInflightMethodLimiter) RPCCallFinished(methodName string) {
if methodName == ingesterPushMethod {
func (g *grpcInflightMethodLimiter) RPCCallFinished(ctx context.Context) {
if v, ok := ctx.Value(ingesterPushStarted).(bool); ok && v {
g.getIngester().FinishPushRequest()
}
}
22 changes: 14 additions & 8 deletions pkg/mimir/grpc_push_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package mimir

import (
"context"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -12,35 +13,40 @@ func TestGrpcInflightMethodLimiter(t *testing.T) {
t.Run("nil push receiver", func(t *testing.T) {
l := newGrpcInflightMethodLimiter(func() pushReceiver { return nil })

require.NoError(t, l.RPCCallStarting("test"))
ctx, err := l.RPCCallStarting(context.Background(), "test", nil)
require.NoError(t, err)
require.NotPanics(t, func() {
l.RPCCallFinished("test")
l.RPCCallFinished(ctx)
})

require.ErrorIs(t, l.RPCCallStarting(ingesterPushMethod), errNoIngester)
ctx, err = l.RPCCallStarting(context.Background(), ingesterPushMethod, nil)
require.ErrorIs(t, err, errNoIngester)
require.Panics(t, func() {
// In practice, this will not be called, since l.RPCCallStarting(ingesterPushMethod) returns error.
l.RPCCallFinished(ingesterPushMethod)
l.RPCCallFinished(context.WithValue(ctx, ingesterPushStarted, true))
})
})

t.Run("push receiver, no error", func(t *testing.T) {
m := &mockPushReceiver{startErr: nil}

l := newGrpcInflightMethodLimiter(func() pushReceiver { return m })
require.NoError(t, l.RPCCallStarting("test"))

ctx, err := l.RPCCallStarting(context.Background(), "test", nil)
require.NoError(t, err)
require.NotPanics(t, func() {
l.RPCCallFinished("test")
l.RPCCallFinished(ctx)
})
require.Equal(t, 0, m.startCalls)
require.Equal(t, 0, m.finishCalls)

require.NoError(t, l.RPCCallStarting(ingesterPushMethod))
ctx, err = l.RPCCallStarting(context.Background(), ingesterPushMethod, nil)
require.NoError(t, err)
require.Equal(t, 1, m.startCalls)
require.Equal(t, 0, m.finishCalls)

require.NotPanics(t, func() {
l.RPCCallFinished(ingesterPushMethod)
l.RPCCallFinished(ctx)
})
require.Equal(t, 1, m.startCalls)
require.Equal(t, 1, m.finishCalls)
Expand Down
5 changes: 5 additions & 0 deletions vendor/github.com/golang/glog/glog_file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 11 additions & 21 deletions vendor/github.com/grafana/dskit/server/limits.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/google.golang.org/grpc/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/google.golang.org/grpc/attributes/attributes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/google.golang.org/grpc/balancer/balancer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 790c6ee

Please sign in to comment.