Skip to content

Commit

Permalink
vendor: bump gRPC to v1.27.1
Browse files Browse the repository at this point in the history
Upgrade gRPC to 1.27.1 (latest is 1.29). This doesn't pick up anything that we need, but it claims to contain some improvements, and now is the right time in the cycle to bump if we're going to.

Notable PRs (from gRPC-go's release notes):

- client: fix race between client-side stream cancellation and compressed server data arriving (grpc/grpc-go#3054)
- clientconn: fix potential deadlock caused by ResetConnectBackoff (grpc/grpc-go#3051)
- internal: fix context leak when stream is not created successfully (grpc/grpc-go#2985)
- server: set and advertise max frame size of 16KB (grpc/grpc-go#3018)
- transport: block reading frames when too many transport control frames are queued (grpc/grpc-go#2970)
    Addresses CVE-2019-9512 (Ping Flood), CVE-2019-9514 (Reset Flood), and CVE-2019-9515 (Settings Flood).
- server: avoid an unnecessary allocation per-RPC for OK status (grpc/grpc-go#2920)
        Special Thanks: @dzbarsky
- server: avoid call to trace.FromContext and resulting allocations when tracing is disabled (grpc/grpc-go#2926)
        Special Thanks: @dzbarsky
- http2client: remove unnecessary allocations for header fields (grpc/grpc-go#2925)
        Special Thanks: @dzbarsky
- status: avoid allocations when returning an OK status (grpc/grpc-go#2929)
        Special Thanks: @dzbarsky
- server: avoid allocations related to tracking excessive pings (grpc/grpc-go#2923)
        Special Thanks: @dzbarsky
- transport: call Unlock in defer to avoid data race (grpc/grpc-go#2953)
- client: fix canceled vs deadline exceeded double-check logic (grpc/grpc-go#2906)
- client: fix race between transport draining and new RPCs (grpc/grpc-go#2919)

Of course there was also a yak shave. Bumping grpc updates this file

https://github.com/grpc/grpc-go/blob/master/health/grpc_health_v1/health.pb.go#L25

Note the IsV3 - used to be IsV2. (the file is included as a dependency via etcd)

This in turn requires us to update github.com/golang/protobuf to v1.4+

At that version, `github.com/golang/protobuf/protoc-gen-go/generator/generator.go`

emits a warning at `init()` time:

> WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

We treat warnings as errors in protoc, so now `make protobuf` fails. I
want to continue treating warnings as errors. So we also bump the
importer, which is grpc-gateway:

```
go list -f '{{.ImportPath}} {{join .Imports " "}}' ./pkg/... ./vendor/... | digraph reverse github.com/cockroachdb/cockroach/vendor/github.com/golang/protobuf/protoc-gen-go/generator
github.com/cockroachdb/cockroach/vendor/github.com/golang/protobuf/protoc-gen-go/generator
github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor
github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/generator
github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/gengateway
github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger
```

That new version of grpc-gateway added a silly warning of its own, so we
now use our own fork that has that warning stripped out.

Release note: None
  • Loading branch information
tbg committed May 21, 2020
1 parent 302479d commit 2206719
Show file tree
Hide file tree
Showing 9 changed files with 3,145 additions and 1,012 deletions.
89 changes: 72 additions & 17 deletions Gopkg.lock

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

25 changes: 24 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ noverify = [
ignored = [
# Non-existent package used by a toy program in c-deps/protobuf.
"github.com/google/protobuf/examples/tutorial",
"github.com/cockroachdb/cockroach/c-deps/protobuf/benchmarks/go",
]

[[constraint]]
Expand Down Expand Up @@ -115,6 +116,16 @@ ignored = [
name = "golang.org/x/crypto"
branch = "master"

[[constraint]]
# This package should be replaced for google.golang.org/protobuf,
# but we (and various deps including etcd) continue to use this
# one. We require v1.4+.
# The package is a wrapper around the suggested replacement
# (google.golang.org/protobuf) so there's no pressing reason
# to do anything.
name = "github.com/golang/protobuf"
version = "=v1.4.1"

[[constraint]]
name = "github.com/gogo/protobuf"
source = "https://github.com/cockroachdb/gogoproto"
Expand Down Expand Up @@ -157,7 +168,19 @@ ignored = [

[[constraint]]
name = "google.golang.org/grpc"
version = "=v1.21.2"
version = "=v1.27.1"

[[constraint]]
# The grpc-gateway protoc plugin prints warnings whenever
# you have a gRPC service without a HttpRule. We have a number
# of those (and it's totally reasonable to).
# For the time being, we use a fork that has the warning removed.
# See:
# https://github.com/grpc-ecosystem/grpc-gateway/commit/ee513453fd80ce577c1a680b14300458072dad5e
# https://github.com/uber/prototool/issues/128
name = "github.com/grpc-ecosystem/grpc-gateway"
branch = "v1.14.5-nowarning"
source = "https://github.com/cockroachdb/grpc-gateway"

[prune]
go-tests = true
Expand Down
3 changes: 2 additions & 1 deletion pkg/cli/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ func MaybeDecorateGRPCError(
if reGRPCAuthFailure.MatchString(msg) {
return connSecurityHint()
}
if reGRPCConnFailed.MatchString(msg) {
if reGRPCConnFailed.MatchString(msg) /* gRPC 1.21 */ ||
status.Code(errors.Cause(err)) == codes.Unavailable /* gRPC 1.27 */ {
return connRefused()
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/rpc/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
opentracing "github.com/opentracing/opentracing-go"
"golang.org/x/sync/syncmap"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/encoding"
encodingproto "google.golang.org/grpc/encoding/proto"
Expand Down Expand Up @@ -898,7 +899,11 @@ func (ctx *Context) grpcDialRaw(
// Add a stats handler to measure client network stats.
dialOpts = append(dialOpts, grpc.WithStatsHandler(ctx.stats.newClient(target)))

dialOpts = append(dialOpts, grpc.WithBackoffMaxDelay(maxBackoff))
// Lower the MaxBackoff (which defaults to ~minutes) to something in the
// ~second range.
backoffConfig := backoff.DefaultConfig
backoffConfig.MaxDelay = maxBackoff
dialOpts = append(dialOpts, grpc.WithConnectParams(grpc.ConnectParams{Backoff: backoffConfig}))
dialOpts = append(dialOpts, grpc.WithKeepaliveParams(clientKeepalive))
dialOpts = append(dialOpts,
grpc.WithInitialWindowSize(initialWindowSize),
Expand Down
Loading

0 comments on commit 2206719

Please sign in to comment.