From f4d82699c2f91df13ad2eaca4fb90710d59657b2 Mon Sep 17 00:00:00 2001 From: Simon Croome Date: Thu, 6 Feb 2020 15:56:59 +0000 Subject: [PATCH] Downgrade protoc-gen-go --- Dockerfile.dapper | 10 +-- Gopkg.lock | 6 +- Gopkg.toml | 2 +- Makefile | 14 ++- directfs/v1/directfs.pb.go | 12 +-- director/v1/director.pb.go | 8 +- filesystem/v1/filesystem.pb.go | 8 +- rdbplugin/v1/rdbplugin.pb.go | 8 +- stats/v1/stats.pb.go | 8 +- supervisor/v1/supervisor.pb.go | 8 +- vendor/google.golang.org/grpc/.travis.yml | 2 +- vendor/google.golang.org/grpc/Makefile | 3 - .../grpc/balancer/balancer.go | 5 ++ .../grpc/balancer/base/balancer.go | 67 +++++---------- vendor/google.golang.org/grpc/clientconn.go | 62 +++++--------- .../grpc/credentials/credentials.go | 79 +---------------- .../google.golang.org/grpc/credentials/tls.go | 9 +- vendor/google.golang.org/grpc/dialoptions.go | 25 +++--- .../grpc/internal/envconfig/envconfig.go | 7 +- .../grpc/internal/internal.go | 2 + .../internal/resolver/dns/dns_resolver.go | 85 +++++++------------ .../grpc/internal/transport/handler_server.go | 2 +- .../grpc/internal/transport/http2_client.go | 3 +- .../grpc/resolver/resolver.go | 10 +++ .../grpc/resolver_conn_wrapper.go | 14 ++- vendor/google.golang.org/grpc/rpc_util.go | 3 +- .../google.golang.org/grpc/service_config.go | 4 +- vendor/google.golang.org/grpc/trace.go | 3 + vendor/google.golang.org/grpc/version.go | 2 +- vendor/google.golang.org/grpc/vet.sh | 2 +- 30 files changed, 173 insertions(+), 300 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index cb5ac34..cd2e769 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -21,11 +21,11 @@ RUN curl -fsSL "$DEP_DOWNLOAD_URL" -o /go/bin/dep \ # soegarots/dataplane-build:latest contains the dataplane C++ versions of protobuf and grpc. -# Install go pieces we need. -RUN for pkg in \ - github.com/golang/protobuf/protoc-gen-go \ - github.com/golang/mock/mockgen \ - ; do echo "++ $pkg"; go get -u $pkg; done +ENV PROTOC_TAG="v1.3.2" +RUN go get -u github.com/golang/mock/mockgen +RUN go get -d -u github.com/golang/protobuf/protoc-gen-go \ + && git -C "$GOPATH/src/github.com/golang/protobuf" checkout $PROTOC_TAG \ + && go install github.com/golang/protobuf/protoc-gen-go WORKDIR /go/src/code.storageos.net/storageos/service ENV DAPPER_SOURCE /go/src/code.storageos.net/storageos/service diff --git a/Gopkg.lock b/Gopkg.lock index 6098766..e7ded9f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -80,7 +80,7 @@ revision = "a86caf926a677e543dd621436dc3ebf2ef9877d4" [[projects]] - digest = "1:de21a2d5b9c8697d83f5ab48f3e8fe3616c33ac4b2d057083662dede0e81488e" + digest = "1:3fe55026bb11519b45c0fc9d848fd779028b868dc62f5563c518cf850c7421d5" name = "google.golang.org/grpc" packages = [ ".", @@ -121,8 +121,8 @@ "tap", ] pruneopts = "UT" - revision = "f495f5b15ae7ccda3b38c53a1bfcde4c1a58a2bc" - version = "v1.27.1" + revision = "f5b0812e6fe574d90da76b205e9eb51f6ddb1919" + version = "v1.26.0" [solve-meta] analyzer-name = "dep" diff --git a/Gopkg.toml b/Gopkg.toml index 53a8004..6716bf7 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -31,7 +31,7 @@ [[constraint]] name = "google.golang.org/grpc" - version = "1.26.0" + version = "=1.26.0" [prune] go-tests = true diff --git a/Makefile b/Makefile index 7ba5a31..f21c256 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,11 @@ go-mocks: # having the files in the GOPATH doesn't work at all. # When building, ensure source files are in: # $(GOPATH)/src/code.storageos.net/storageos/service/ + for dir in dbplugin/v1/mock_rdbplugin filesystem/v1/mock_filesystem \ + director/v1/mock_director directfs/v1/mock_directfs stats/v1/mock_stats; \ + do \ + mkdir -p $$dir; \ + done mockgen code.storageos.net/storageos/service/rdbplugin/v1 RdbPluginClient > rdbplugin/v1/mock_rdbplugin/rdbplugin_mock.go mockgen code.storageos.net/storageos/service/filesystem/v1 FsClient > filesystem/v1/mock_filesystem/filesystem_mock.go @@ -63,7 +68,7 @@ go-mocks: cxx: ${GRPC_CPP_OBJ} ${PBUF_CPP_OBJ} -clean: grpc_clean vis_clean +clean: grpc_clean vis_clean mock_clean distclean: clean @@ -74,6 +79,13 @@ grpc: $(GRPC_OBJ) grpc_clean: rm -f $(GRPC_ALLOBJ) +mock_clean: + for dir in dbplugin/v1/mock_rdbplugin filesystem/v1/mock_filesystem \ + director/v1/mock_director directfs/v1/mock_directfs stats/v1/mock_stats; \ + do \ + rm -f $$dir/*.go; \ + done + vis: cd visualiser && $(MAKE) diff --git a/directfs/v1/directfs.pb.go b/directfs/v1/directfs.pb.go index 7c4fdbd..57530e0 100644 --- a/directfs/v1/directfs.pb.go +++ b/directfs/v1/directfs.pb.go @@ -1220,11 +1220,11 @@ var fileDescriptor_a98ffea917a5fa2f = []byte{ // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConnInterface +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 +const _ = grpc.SupportPackageIsVersion4 // DfsInitiatorClient is the client API for DfsInitiator service. // @@ -1300,10 +1300,10 @@ type DfsInitiatorClient interface { } type dfsInitiatorClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewDfsInitiatorClient(cc grpc.ClientConnInterface) DfsInitiatorClient { +func NewDfsInitiatorClient(cc *grpc.ClientConn) DfsInitiatorClient { return &dfsInitiatorClient{cc} } @@ -1987,10 +1987,10 @@ type DfsResponderClient interface { } type dfsResponderClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewDfsResponderClient(cc grpc.ClientConnInterface) DfsResponderClient { +func NewDfsResponderClient(cc *grpc.ClientConn) DfsResponderClient { return &dfsResponderClient{cc} } diff --git a/director/v1/director.pb.go b/director/v1/director.pb.go index 06a8fa9..24eb4d0 100644 --- a/director/v1/director.pb.go +++ b/director/v1/director.pb.go @@ -682,11 +682,11 @@ var fileDescriptor_29bb3702600586b0 = []byte{ // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConnInterface +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 +const _ = grpc.SupportPackageIsVersion4 // DirectorClient is the client API for Director service. // @@ -766,10 +766,10 @@ type DirectorClient interface { } type directorClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewDirectorClient(cc grpc.ClientConnInterface) DirectorClient { +func NewDirectorClient(cc *grpc.ClientConn) DirectorClient { return &directorClient{cc} } diff --git a/filesystem/v1/filesystem.pb.go b/filesystem/v1/filesystem.pb.go index 8f288d1..de30842 100644 --- a/filesystem/v1/filesystem.pb.go +++ b/filesystem/v1/filesystem.pb.go @@ -750,11 +750,11 @@ var fileDescriptor_0a9f8093c6c7067e = []byte{ // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConnInterface +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 +const _ = grpc.SupportPackageIsVersion4 // FsClient is the client API for Fs service. // @@ -826,10 +826,10 @@ type FsClient interface { } type fsClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewFsClient(cc grpc.ClientConnInterface) FsClient { +func NewFsClient(cc *grpc.ClientConn) FsClient { return &fsClient{cc} } diff --git a/rdbplugin/v1/rdbplugin.pb.go b/rdbplugin/v1/rdbplugin.pb.go index 64f01ec..0511369 100644 --- a/rdbplugin/v1/rdbplugin.pb.go +++ b/rdbplugin/v1/rdbplugin.pb.go @@ -437,11 +437,11 @@ var fileDescriptor_883053c55cea96f3 = []byte{ // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConnInterface +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 +const _ = grpc.SupportPackageIsVersion4 // RdbPluginClient is the client API for RdbPlugin service. // @@ -494,10 +494,10 @@ type RdbPluginClient interface { } type rdbPluginClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewRdbPluginClient(cc grpc.ClientConnInterface) RdbPluginClient { +func NewRdbPluginClient(cc *grpc.ClientConn) RdbPluginClient { return &rdbPluginClient{cc} } diff --git a/stats/v1/stats.pb.go b/stats/v1/stats.pb.go index 6bb73b1..31bfde2 100644 --- a/stats/v1/stats.pb.go +++ b/stats/v1/stats.pb.go @@ -496,11 +496,11 @@ var fileDescriptor_b4756a0aec8b9d44 = []byte{ // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConnInterface +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 +const _ = grpc.SupportPackageIsVersion4 // StatsClient is the client API for Stats service. // @@ -540,10 +540,10 @@ type StatsClient interface { } type statsClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewStatsClient(cc grpc.ClientConnInterface) StatsClient { +func NewStatsClient(cc *grpc.ClientConn) StatsClient { return &statsClient{cc} } diff --git a/supervisor/v1/supervisor.pb.go b/supervisor/v1/supervisor.pb.go index b17d53d..651dd3a 100644 --- a/supervisor/v1/supervisor.pb.go +++ b/supervisor/v1/supervisor.pb.go @@ -497,11 +497,11 @@ var fileDescriptor_b8b9452d77b1c7d2 = []byte{ // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConnInterface +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 +const _ = grpc.SupportPackageIsVersion4 // SupervisorClient is the client API for Supervisor service. // @@ -530,10 +530,10 @@ type SupervisorClient interface { } type supervisorClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewSupervisorClient(cc grpc.ClientConnInterface) SupervisorClient { +func NewSupervisorClient(cc *grpc.ClientConn) SupervisorClient { return &supervisorClient{cc} } diff --git a/vendor/google.golang.org/grpc/.travis.yml b/vendor/google.golang.org/grpc/.travis.yml index a11e8cb..819c1e2 100644 --- a/vendor/google.golang.org/grpc/.travis.yml +++ b/vendor/google.golang.org/grpc/.travis.yml @@ -35,7 +35,7 @@ install: script: - set -e - - if [[ -n "${TESTEXTRAS}" ]]; then examples/examples_test.sh; interop/interop_test.sh; make testsubmodule; exit 0; fi + - if [[ -n "${TESTEXTRAS}" ]]; then examples/examples_test.sh; interop/interop_test.sh; exit 0; fi - if [[ -n "${VET}" ]]; then ./vet.sh; fi - if [[ -n "${GAE}" ]]; then make testappengine; exit 0; fi - if [[ -n "${RACE}" ]]; then make testrace; exit 0; fi diff --git a/vendor/google.golang.org/grpc/Makefile b/vendor/google.golang.org/grpc/Makefile index 410f7d5..db982aa 100644 --- a/vendor/google.golang.org/grpc/Makefile +++ b/vendor/google.golang.org/grpc/Makefile @@ -19,9 +19,6 @@ proto: test: testdeps go test -cpu 1,4 -timeout 7m google.golang.org/grpc/... -testsubmodule: testdeps - cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/... - testappengine: testappenginedeps goapp test -cpu 1,4 -timeout 7m google.golang.org/grpc/... diff --git a/vendor/google.golang.org/grpc/balancer/balancer.go b/vendor/google.golang.org/grpc/balancer/balancer.go index 9258858..531a174 100644 --- a/vendor/google.golang.org/grpc/balancer/balancer.go +++ b/vendor/google.golang.org/grpc/balancer/balancer.go @@ -203,6 +203,11 @@ type ConfigParser interface { ParseConfig(LoadBalancingConfigJSON json.RawMessage) (serviceconfig.LoadBalancingConfig, error) } +// PickOptions is a type alias of PickInfo for legacy reasons. +// +// Deprecated: use PickInfo instead. +type PickOptions = PickInfo + // PickInfo contains additional information for the Pick operation. type PickInfo struct { // FullMethodName is the method name that NewClientStream() is called diff --git a/vendor/google.golang.org/grpc/balancer/base/balancer.go b/vendor/google.golang.org/grpc/balancer/base/balancer.go index d7d7291..d952f09 100644 --- a/vendor/google.golang.org/grpc/balancer/base/balancer.go +++ b/vendor/google.golang.org/grpc/balancer/base/balancer.go @@ -21,7 +21,6 @@ package base import ( "context" "errors" - "fmt" "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" @@ -77,9 +76,6 @@ type baseBalancer struct { picker balancer.Picker v2Picker balancer.V2Picker config Config - - resolverErr error // the last error reported by the resolver; cleared on successful resolution - connErr error // the last connection error; cleared upon leaving TransientFailure } func (b *baseBalancer) HandleResolvedAddrs(addrs []resolver.Address, err error) { @@ -87,23 +83,13 @@ func (b *baseBalancer) HandleResolvedAddrs(addrs []resolver.Address, err error) } func (b *baseBalancer) ResolverError(err error) { - b.resolverErr = err - if len(b.subConns) == 0 { - b.state = connectivity.TransientFailure - } - if b.state != connectivity.TransientFailure { - // The picker will not change since the balancer does not currently - // report an error. - return - } - b.regeneratePicker() - if b.picker != nil { - b.cc.UpdateBalancerState(b.state, b.picker) - } else { - b.cc.UpdateState(balancer.State{ - ConnectivityState: b.state, - Picker: b.v2Picker, - }) + switch b.state { + case connectivity.TransientFailure, connectivity.Idle, connectivity.Connecting: + if b.picker != nil { + b.picker = NewErrPicker(err) + } else { + b.v2Picker = NewErrPickerV2(err) + } } } @@ -113,12 +99,6 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error { if grpclog.V(2) { grpclog.Infoln("base.baseBalancer: got new ClientConn state: ", s) } - if len(s.ResolverState.Addresses) == 0 { - b.ResolverError(errors.New("produced zero addresses")) - return balancer.ErrBadResolverState - } - // Successful resolution; clear resolver error and ensure we return nil. - b.resolverErr = nil // addrsSet is the set converted from addrs, it's used for quick lookup of an address. addrsSet := make(map[resolver.Address]struct{}) for _, a := range s.ResolverState.Addresses { @@ -147,30 +127,24 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error { return nil } -// mergeErrors builds an error from the last connection error and the last -// resolver error. Must only be called if b.state is TransientFailure. -func (b *baseBalancer) mergeErrors() error { - // connErr must always be non-nil unless there are no SubConns, in which - // case resolverErr must be non-nil. - if b.connErr == nil { - return fmt.Errorf("last resolver error: %v", b.resolverErr) - } - if b.resolverErr == nil { - return fmt.Errorf("last connection error: %v", b.connErr) - } - return fmt.Errorf("last connection error: %v; last resolver error: %v", b.connErr, b.resolverErr) -} - // regeneratePicker takes a snapshot of the balancer, and generates a picker // from it. The picker is -// - errPicker if the balancer is in TransientFailure, +// - errPicker with ErrTransientFailure if the balancer is in TransientFailure, // - built by the pickerBuilder with all READY SubConns otherwise. -func (b *baseBalancer) regeneratePicker() { +func (b *baseBalancer) regeneratePicker(err error) { if b.state == connectivity.TransientFailure { if b.pickerBuilder != nil { b.picker = NewErrPicker(balancer.ErrTransientFailure) } else { - b.v2Picker = NewErrPickerV2(balancer.TransientFailureError(b.mergeErrors())) + if err != nil { + b.v2Picker = NewErrPickerV2(balancer.TransientFailureError(err)) + } else { + // This means the last subchannel transition was not to + // TransientFailure (otherwise err must be set), but the + // aggregate state of the balancer is TransientFailure, meaning + // there are no other addresses. + b.v2Picker = NewErrPickerV2(balancer.TransientFailureError(errors.New("resolver returned no addresses"))) + } } return } @@ -226,9 +200,6 @@ func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.Su oldAggrState := b.state b.state = b.csEvltr.RecordTransition(oldS, s) - // Set or clear the last connection error accordingly. - b.connErr = state.ConnectionError - // Regenerate picker when one of the following happens: // - this sc became ready from not-ready // - this sc became not-ready from ready @@ -236,7 +207,7 @@ func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.Su // - the aggregated state of balancer became non-TransientFailure from TransientFailure if (s == connectivity.Ready) != (oldS == connectivity.Ready) || (b.state == connectivity.TransientFailure) != (oldAggrState == connectivity.TransientFailure) { - b.regeneratePicker() + b.regeneratePicker(state.ConnectionError) } if b.picker != nil { diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index f58740b..14ce9c7 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -239,26 +239,25 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * if cc.dopts.bs == nil { cc.dopts.bs = backoff.DefaultExponential } - - // Determine the resolver to use. - cc.parsedTarget = parseTarget(cc.target) - grpclog.Infof("parsed scheme: %q", cc.parsedTarget.Scheme) - resolverBuilder := cc.getResolver(cc.parsedTarget.Scheme) - if resolverBuilder == nil { - // If resolver builder is still nil, the parsed target's scheme is - // not registered. Fallback to default resolver and set Endpoint to - // the original target. - grpclog.Infof("scheme %q not registered, fallback to default scheme", cc.parsedTarget.Scheme) - cc.parsedTarget = resolver.Target{ - Scheme: resolver.GetDefaultScheme(), - Endpoint: target, - } - resolverBuilder = cc.getResolver(cc.parsedTarget.Scheme) - if resolverBuilder == nil { - return nil, fmt.Errorf("could not get resolver for default scheme: %q", cc.parsedTarget.Scheme) + if cc.dopts.resolverBuilder == nil { + // Only try to parse target when resolver builder is not already set. + cc.parsedTarget = parseTarget(cc.target) + grpclog.Infof("parsed scheme: %q", cc.parsedTarget.Scheme) + cc.dopts.resolverBuilder = resolver.Get(cc.parsedTarget.Scheme) + if cc.dopts.resolverBuilder == nil { + // If resolver builder is still nil, the parsed target's scheme is + // not registered. Fallback to default resolver and set Endpoint to + // the original target. + grpclog.Infof("scheme %q not registered, fallback to default scheme", cc.parsedTarget.Scheme) + cc.parsedTarget = resolver.Target{ + Scheme: resolver.GetDefaultScheme(), + Endpoint: target, + } + cc.dopts.resolverBuilder = resolver.Get(cc.parsedTarget.Scheme) } + } else { + cc.parsedTarget = resolver.Target{Endpoint: target} } - creds := cc.dopts.copts.TransportCredentials if creds != nil && creds.Info().ServerName != "" { cc.authority = creds.Info().ServerName @@ -298,14 +297,14 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * } // Build the resolver. - rWrapper, err := newCCResolverWrapper(cc, resolverBuilder) + rWrapper, err := newCCResolverWrapper(cc) if err != nil { return nil, fmt.Errorf("failed to build resolver: %v", err) } + cc.mu.Lock() cc.resolverWrapper = rWrapper cc.mu.Unlock() - // A blocking dial blocks until the clientConn is ready. if cc.dopts.block { for { @@ -444,20 +443,6 @@ func (csm *connectivityStateManager) getNotifyChan() <-chan struct{} { return csm.notifyChan } -// ClientConnInterface defines the functions clients need to perform unary and -// streaming RPCs. It is implemented by *ClientConn, and is only intended to -// be referenced by generated code. -type ClientConnInterface interface { - // Invoke performs a unary RPC and returns after the response is received - // into reply. - Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...CallOption) error - // NewStream begins a streaming RPC. - NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error) -} - -// Assert *ClientConn implements ClientConnInterface. -var _ ClientConnInterface = (*ClientConn)(nil) - // ClientConn represents a virtual connection to a conceptual endpoint, to // perform RPCs. // @@ -1557,12 +1542,3 @@ func (c *channelzChannel) ChannelzMetric() *channelz.ChannelInternalMetric { // Deprecated: This error is never returned by grpc and should not be // referenced by users. var ErrClientConnTimeout = errors.New("grpc: timed out when dialing") - -func (cc *ClientConn) getResolver(scheme string) resolver.Builder { - for _, rb := range cc.dopts.resolvers { - if cc.parsedTarget.Scheme == rb.Scheme() { - return rb - } - } - return resolver.Get(cc.parsedTarget.Scheme) -} diff --git a/vendor/google.golang.org/grpc/credentials/credentials.go b/vendor/google.golang.org/grpc/credentials/credentials.go index 845ce5d..667cf6b 100644 --- a/vendor/google.golang.org/grpc/credentials/credentials.go +++ b/vendor/google.golang.org/grpc/credentials/credentials.go @@ -25,7 +25,6 @@ package credentials // import "google.golang.org/grpc/credentials" import ( "context" "errors" - "fmt" "net" "github.com/golang/protobuf/proto" @@ -51,48 +50,6 @@ type PerRPCCredentials interface { RequireTransportSecurity() bool } -// SecurityLevel defines the protection level on an established connection. -// -// This API is experimental. -type SecurityLevel int - -const ( - // NoSecurity indicates a connection is insecure. - // The zero SecurityLevel value is invalid for backward compatibility. - NoSecurity SecurityLevel = iota + 1 - // IntegrityOnly indicates a connection only provides integrity protection. - IntegrityOnly - // PrivacyAndIntegrity indicates a connection provides both privacy and integrity protection. - PrivacyAndIntegrity -) - -// String returns SecurityLevel in a string format. -func (s SecurityLevel) String() string { - switch s { - case NoSecurity: - return "NoSecurity" - case IntegrityOnly: - return "IntegrityOnly" - case PrivacyAndIntegrity: - return "PrivacyAndIntegrity" - } - return fmt.Sprintf("invalid SecurityLevel: %v", int(s)) -} - -// CommonAuthInfo contains authenticated information common to AuthInfo implementations. -// It should be embedded in a struct implementing AuthInfo to provide additional information -// about the credentials. -// -// This API is experimental. -type CommonAuthInfo struct { - SecurityLevel SecurityLevel -} - -// GetCommonAuthInfo returns the pointer to CommonAuthInfo struct. -func (c *CommonAuthInfo) GetCommonAuthInfo() *CommonAuthInfo { - return c -} - // ProtocolInfo provides information regarding the gRPC wire protocol version, // security protocol, security protocol version in use, server name, etc. type ProtocolInfo struct { @@ -107,8 +64,6 @@ type ProtocolInfo struct { } // AuthInfo defines the common interface for the auth information the users are interested in. -// A struct that implements AuthInfo should embed CommonAuthInfo by including additional -// information about the credentials in it. type AuthInfo interface { AuthType() string } @@ -123,8 +78,7 @@ type TransportCredentials interface { // ClientHandshake does the authentication handshake specified by the corresponding // authentication protocol on rawConn for clients. It returns the authenticated // connection and the corresponding auth information about the connection. - // The auth information should embed CommonAuthInfo to return additional information about - // the credentials. Implementations must use the provided context to implement timely cancellation. + // Implementations must use the provided context to implement timely cancellation. // gRPC will try to reconnect if the error returned is a temporary error // (io.EOF, context.DeadlineExceeded or err.Temporary() == true). // If the returned error is a wrapper error, implementations should make sure that @@ -134,8 +88,7 @@ type TransportCredentials interface { ClientHandshake(context.Context, string, net.Conn) (net.Conn, AuthInfo, error) // ServerHandshake does the authentication handshake for servers. It returns // the authenticated connection and the corresponding auth information about - // the connection. The auth information should embed CommonAuthInfo to return additional information - // about the credentials. + // the connection. // // If the returned net.Conn is closed, it MUST close the net.Conn provided. ServerHandshake(net.Conn) (net.Conn, AuthInfo, error) @@ -174,8 +127,6 @@ type Bundle interface { type RequestInfo struct { // The method passed to Invoke or NewStream for this RPC. (For proto methods, this has the format "/some.Service/Method") Method string - // AuthInfo contains the information from a security handshake (TransportCredentials.ClientHandshake, TransportCredentials.ServerHandshake) - AuthInfo AuthInfo } // requestInfoKey is a struct to be used as the key when attaching a RequestInfo to a context object. @@ -189,32 +140,6 @@ func RequestInfoFromContext(ctx context.Context) (ri RequestInfo, ok bool) { return } -// CheckSecurityLevel checks if a connection's security level is greater than or equal to the specified one. -// It returns success if 1) the condition is satisified or 2) AuthInfo struct does not implement GetCommonAuthInfo() method -// or 3) CommonAuthInfo.SecurityLevel has an invalid zero value. For 2) and 3), it is for the purpose of backward-compatibility. -// -// This API is experimental. -func CheckSecurityLevel(ctx context.Context, level SecurityLevel) error { - type internalInfo interface { - GetCommonAuthInfo() *CommonAuthInfo - } - ri, _ := RequestInfoFromContext(ctx) - if ri.AuthInfo == nil { - return errors.New("unable to obtain SecurityLevel from context") - } - if ci, ok := ri.AuthInfo.(internalInfo); ok { - // CommonAuthInfo.SecurityLevel has an invalid value. - if ci.GetCommonAuthInfo().SecurityLevel == 0 { - return nil - } - if ci.GetCommonAuthInfo().SecurityLevel < level { - return fmt.Errorf("requires SecurityLevel %v; connection has %v", level, ci.GetCommonAuthInfo().SecurityLevel) - } - } - // The condition is satisfied or AuthInfo struct does not implement GetCommonAuthInfo() method. - return nil -} - func init() { internal.NewRequestInfoContext = func(ctx context.Context, ri RequestInfo) context.Context { return context.WithValue(ctx, requestInfoKey{}, ri) diff --git a/vendor/google.golang.org/grpc/credentials/tls.go b/vendor/google.golang.org/grpc/credentials/tls.go index 28b4f62..7c33613 100644 --- a/vendor/google.golang.org/grpc/credentials/tls.go +++ b/vendor/google.golang.org/grpc/credentials/tls.go @@ -33,7 +33,6 @@ import ( // It implements the AuthInfo interface. type TLSInfo struct { State tls.ConnectionState - CommonAuthInfo } // AuthType returns the type of TLSInfo as a string. @@ -82,28 +81,24 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, authority string, rawCon errChannel := make(chan error, 1) go func() { errChannel <- conn.Handshake() - close(errChannel) }() select { case err := <-errChannel: if err != nil { - conn.Close() return nil, nil, err } case <-ctx.Done(): - conn.Close() return nil, nil, ctx.Err() } - return internal.WrapSyscallConn(rawConn, conn), TLSInfo{conn.ConnectionState(), CommonAuthInfo{PrivacyAndIntegrity}}, nil + return internal.WrapSyscallConn(rawConn, conn), TLSInfo{conn.ConnectionState()}, nil } func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) { conn := tls.Server(rawConn, c.config) if err := conn.Handshake(); err != nil { - conn.Close() return nil, nil, err } - return internal.WrapSyscallConn(rawConn, conn), TLSInfo{conn.ConnectionState(), CommonAuthInfo{PrivacyAndIntegrity}}, nil + return internal.WrapSyscallConn(rawConn, conn), TLSInfo{conn.ConnectionState()}, nil } func (c *tlsCreds) Clone() TransportCredentials { diff --git a/vendor/google.golang.org/grpc/dialoptions.go b/vendor/google.golang.org/grpc/dialoptions.go index 63f5ae2..9af3eef 100644 --- a/vendor/google.golang.org/grpc/dialoptions.go +++ b/vendor/google.golang.org/grpc/dialoptions.go @@ -58,7 +58,9 @@ type dialOptions struct { callOptions []CallOption // This is used by v1 balancer dial option WithBalancer to support v1 // balancer, and also by WithBalancerName dial option. - balancerBuilder balancer.Builder + balancerBuilder balancer.Builder + // This is to support grpclb. + resolverBuilder resolver.Builder channelzParentID int64 disableServiceConfig bool disableRetry bool @@ -71,7 +73,6 @@ type dialOptions struct { // resolver.ResolveNow(). The user will have no need to configure this, but // we need to be able to configure this in tests. resolveNowBackoff func(int) time.Duration - resolvers []resolver.Builder } // DialOption configures how we set up the connection. @@ -230,6 +231,13 @@ func WithBalancerName(balancerName string) DialOption { }) } +// withResolverBuilder is only for grpclb. +func withResolverBuilder(b resolver.Builder) DialOption { + return newFuncDialOption(func(o *dialOptions) { + o.resolverBuilder = b + }) +} + // WithServiceConfig returns a DialOption which has a channel to read the // service configuration. // @@ -357,6 +365,7 @@ func WithContextDialer(f func(context.Context, string) (net.Conn, error)) DialOp } func init() { + internal.WithResolverBuilder = withResolverBuilder internal.WithHealthCheckFunc = withHealthCheckFunc } @@ -580,15 +589,3 @@ func withResolveNowBackoff(f func(int) time.Duration) DialOption { o.resolveNowBackoff = f }) } - -// WithResolvers allows a list of resolver implementations to be registered -// locally with the ClientConn without needing to be globally registered via -// resolver.Register. They will be matched against the scheme used for the -// current Dial only, and will take precedence over the global registry. -// -// This API is EXPERIMENTAL. -func WithResolvers(rs ...resolver.Builder) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.resolvers = append(o.resolvers, rs...) - }) -} diff --git a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go index ae6c897..3ee8740 100644 --- a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go +++ b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go @@ -25,14 +25,11 @@ import ( ) const ( - prefix = "GRPC_GO_" - retryStr = prefix + "RETRY" - txtErrIgnoreStr = prefix + "IGNORE_TXT_ERRORS" + prefix = "GRPC_GO_" + retryStr = prefix + "RETRY" ) var ( // Retry is set if retry is explicitly enabled via "GRPC_GO_RETRY=on". Retry = strings.EqualFold(os.Getenv(retryStr), "on") - // TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false"). - TXTErrIgnore = !strings.EqualFold(os.Getenv(retryStr), "false") ) diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go index 0912f0b..eae18e1 100644 --- a/vendor/google.golang.org/grpc/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/internal.go @@ -28,6 +28,8 @@ import ( ) var ( + // WithResolverBuilder is set by dialoptions.go + WithResolverBuilder interface{} // func (resolver.Builder) grpc.DialOption // WithHealthCheckFunc is set by dialoptions.go WithHealthCheckFunc interface{} // func (HealthChecker) DialOption // HealthCheckFunc is used to provide client-side LB channel health checking diff --git a/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go b/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go index c368db6..7705ca2 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go +++ b/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go @@ -33,7 +33,6 @@ import ( "time" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal/envconfig" "google.golang.org/grpc/internal/grpcrand" "google.golang.org/grpc/resolver" "google.golang.org/grpc/serviceconfig" @@ -205,12 +204,8 @@ func (d *dnsResolver) watcher() { case <-d.rn: } - state, err := d.lookup() - if err != nil { - d.cc.ReportError(err) - } else { - d.cc.UpdateState(*state) - } + state := d.lookup() + d.cc.UpdateState(*state) // Sleep to prevent excessive re-resolutions. Incoming resolution requests // will be queued in d.rn. @@ -224,37 +219,33 @@ func (d *dnsResolver) watcher() { } } -func (d *dnsResolver) lookupSRV() ([]resolver.Address, error) { +func (d *dnsResolver) lookupSRV() []resolver.Address { if !EnableSRVLookups { - return nil, nil + return nil } var newAddrs []resolver.Address _, srvs, err := d.resolver.LookupSRV(d.ctx, "grpclb", "tcp", d.host) if err != nil { - err = handleDNSError(err, "SRV") // may become nil - return nil, err + grpclog.Infof("grpc: failed dns SRV record lookup due to %v.\n", err) + return nil } for _, s := range srvs { lbAddrs, err := d.resolver.LookupHost(d.ctx, s.Target) if err != nil { - err = handleDNSError(err, "A") // may become nil - if err == nil { - // If there are other SRV records, look them up and ignore this - // one that does not exist. - continue - } - return nil, err + grpclog.Infof("grpc: failed load balancer address dns lookup due to %v.\n", err) + continue } for _, a := range lbAddrs { - ip, ok := formatIP(a) + a, ok := formatIP(a) if !ok { - return nil, fmt.Errorf("dns: error parsing A record IP address %v", a) + grpclog.Errorf("grpc: failed IP parsing due to %v.\n", err) + continue } - addr := ip + ":" + strconv.Itoa(int(s.Port)) + addr := a + ":" + strconv.Itoa(int(s.Port)) newAddrs = append(newAddrs, resolver.Address{Addr: addr, Type: resolver.GRPCLB, ServerName: s.Target}) } } - return newAddrs, nil + return newAddrs } var filterError = func(err error) error { @@ -267,22 +258,13 @@ var filterError = func(err error) error { return err } -func handleDNSError(err error, lookupType string) error { - err = filterError(err) - if err != nil { - err = fmt.Errorf("dns: %v record lookup error: %v", lookupType, err) - grpclog.Infoln(err) - } - return err -} - func (d *dnsResolver) lookupTXT() *serviceconfig.ParseResult { ss, err := d.resolver.LookupTXT(d.ctx, txtPrefix+d.host) if err != nil { - if envconfig.TXTErrIgnore { - return nil - } - if err = handleDNSError(err, "TXT"); err != nil { + err = filterError(err) + if err != nil { + err = fmt.Errorf("error from DNS TXT record lookup: %v", err) + grpclog.Infoln("grpc:", err) return &serviceconfig.ParseResult{Err: err} } return nil @@ -294,7 +276,7 @@ func (d *dnsResolver) lookupTXT() *serviceconfig.ParseResult { // TXT record must have "grpc_config=" attribute in order to be used as service config. if !strings.HasPrefix(res, txtAttribute) { - grpclog.Warningf("dns: TXT record %v missing %v attribute", res, txtAttribute) + grpclog.Warningf("grpc: DNS TXT record %v missing %v attribute", res, txtAttribute) // This is not an error; it is the equivalent of not having a service config. return nil } @@ -302,37 +284,34 @@ func (d *dnsResolver) lookupTXT() *serviceconfig.ParseResult { return d.cc.ParseServiceConfig(sc) } -func (d *dnsResolver) lookupHost() ([]resolver.Address, error) { +func (d *dnsResolver) lookupHost() []resolver.Address { var newAddrs []resolver.Address addrs, err := d.resolver.LookupHost(d.ctx, d.host) if err != nil { - err = handleDNSError(err, "A") - return nil, err + grpclog.Warningf("grpc: failed dns A record lookup due to %v.\n", err) + return nil } for _, a := range addrs { - ip, ok := formatIP(a) + a, ok := formatIP(a) if !ok { - return nil, fmt.Errorf("dns: error parsing A record IP address %v", a) + grpclog.Errorf("grpc: failed IP parsing due to %v.\n", err) + continue } - addr := ip + ":" + d.port + addr := a + ":" + d.port newAddrs = append(newAddrs, resolver.Address{Addr: addr}) } - return newAddrs, nil + return newAddrs } -func (d *dnsResolver) lookup() (*resolver.State, error) { - srv, srvErr := d.lookupSRV() - addrs, hostErr := d.lookupHost() - if hostErr != nil && (srvErr != nil || len(srv) == 0) { - return nil, hostErr - } +func (d *dnsResolver) lookup() *resolver.State { + srv := d.lookupSRV() state := &resolver.State{ - Addresses: append(addrs, srv...), + Addresses: append(d.lookupHost(), srv...), } if !d.disableServiceConfig { state.ServiceConfig = d.lookupTXT() } - return state, nil + return state } // formatIP returns ok = false if addr is not a valid textual representation of an IP address. @@ -418,12 +397,12 @@ func canaryingSC(js string) string { var rcs []rawChoice err := json.Unmarshal([]byte(js), &rcs) if err != nil { - grpclog.Warningf("dns: error parsing service config json: %v", err) + grpclog.Warningf("grpc: failed to parse service config json string due to %v.\n", err) return "" } cliHostname, err := os.Hostname() if err != nil { - grpclog.Warningf("dns: error getting client hostname: %v", err) + grpclog.Warningf("grpc: failed to get client hostname due to %v.\n", err) return "" } var sc string diff --git a/vendor/google.golang.org/grpc/internal/transport/handler_server.go b/vendor/google.golang.org/grpc/internal/transport/handler_server.go index c3c32da..fbf01d5 100644 --- a/vendor/google.golang.org/grpc/internal/transport/handler_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/handler_server.go @@ -338,7 +338,7 @@ func (ht *serverHandlerTransport) HandleStreams(startStream func(*Stream), trace Addr: ht.RemoteAddr(), } if req.TLS != nil { - pr.AuthInfo = credentials.TLSInfo{State: *req.TLS, CommonAuthInfo: credentials.CommonAuthInfo{credentials.PrivacyAndIntegrity}} + pr.AuthInfo = credentials.TLSInfo{State: *req.TLS} } ctx = metadata.NewIncomingContext(ctx, ht.headerMD) s.ctx = peer.NewContext(ctx, pr) diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index 2d6feeb..e189356 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -403,8 +403,7 @@ func (t *http2Client) getPeer() *peer.Peer { func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) ([]hpack.HeaderField, error) { aud := t.createAudience(callHdr) ri := credentials.RequestInfo{ - Method: callHdr.Method, - AuthInfo: t.authInfo, + Method: callHdr.Method, } ctxWithRequestInfo := internal.NewRequestInfoContext.(func(context.Context, credentials.RequestInfo) context.Context)(ctx, ri) authData, err := t.getTrAuthData(ctxWithRequestInfo, aud) diff --git a/vendor/google.golang.org/grpc/resolver/resolver.go b/vendor/google.golang.org/grpc/resolver/resolver.go index fe14b2f..03567d7 100644 --- a/vendor/google.golang.org/grpc/resolver/resolver.go +++ b/vendor/google.golang.org/grpc/resolver/resolver.go @@ -124,6 +124,11 @@ type Address struct { Metadata interface{} } +// BuildOption is a type alias of BuildOptions for legacy reasons. +// +// Deprecated: use BuildOptions instead. +type BuildOption = BuildOptions + // BuildOptions includes additional information for the builder to create // the resolver. type BuildOptions struct { @@ -230,6 +235,11 @@ type Builder interface { Scheme() string } +// ResolveNowOption is a type alias of ResolveNowOptions for legacy reasons. +// +// Deprecated: use ResolveNowOptions instead. +type ResolveNowOption = ResolveNowOptions + // ResolveNowOptions includes additional information for ResolveNow. type ResolveNowOptions struct{} diff --git a/vendor/google.golang.org/grpc/resolver_conn_wrapper.go b/vendor/google.golang.org/grpc/resolver_conn_wrapper.go index 3eaf724..89ba9fa 100644 --- a/vendor/google.golang.org/grpc/resolver_conn_wrapper.go +++ b/vendor/google.golang.org/grpc/resolver_conn_wrapper.go @@ -34,7 +34,7 @@ import ( ) // ccResolverWrapper is a wrapper on top of cc for resolvers. -// It implements resolver.ClientConn interface. +// It implements resolver.ClientConnection interface. type ccResolverWrapper struct { cc *ClientConn resolverMu sync.Mutex @@ -74,9 +74,15 @@ func parseTarget(target string) (ret resolver.Target) { return ret } -// newCCResolverWrapper uses the resolver.Builder to build a Resolver and -// returns a ccResolverWrapper object which wraps the newly built resolver. -func newCCResolverWrapper(cc *ClientConn, rb resolver.Builder) (*ccResolverWrapper, error) { +// newCCResolverWrapper uses the resolver.Builder stored in the ClientConn to +// build a Resolver and returns a ccResolverWrapper object which wraps the +// newly built resolver. +func newCCResolverWrapper(cc *ClientConn) (*ccResolverWrapper, error) { + rb := cc.dopts.resolverBuilder + if rb == nil { + return nil, fmt.Errorf("could not get resolver for scheme: %q", cc.parsedTarget.Scheme) + } + ccr := &ccResolverWrapper{ cc: cc, done: grpcsync.NewEvent(), diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go index d3a4adc..edaba79 100644 --- a/vendor/google.golang.org/grpc/rpc_util.go +++ b/vendor/google.golang.org/grpc/rpc_util.go @@ -871,7 +871,7 @@ type channelzData struct { // The SupportPackageIsVersion variables are referenced from generated protocol // buffer files to ensure compatibility with the gRPC version used. The latest -// support package version is 6. +// support package version is 5. // // Older versions are kept for compatibility. They may be removed if // compatibility cannot be maintained. @@ -881,7 +881,6 @@ const ( SupportPackageIsVersion3 = true SupportPackageIsVersion4 = true SupportPackageIsVersion5 = true - SupportPackageIsVersion6 = true ) const grpcUA = "grpc-go/" + Version diff --git a/vendor/google.golang.org/grpc/service_config.go b/vendor/google.golang.org/grpc/service_config.go index 5a80a57..4f8836d 100644 --- a/vendor/google.golang.org/grpc/service_config.go +++ b/vendor/google.golang.org/grpc/service_config.go @@ -136,9 +136,9 @@ type retryPolicy struct { maxAttempts int // Exponential backoff parameters. The initial retry attempt will occur at - // random(0, initialBackoff). In general, the nth attempt will occur at + // random(0, initialBackoffMS). In general, the nth attempt will occur at // random(0, - // min(initialBackoff*backoffMultiplier**(n-1), maxBackoff)). + // min(initialBackoffMS*backoffMultiplier**(n-1), maxBackoffMS)). // // These fields are required and must be greater than zero. initialBackoff time.Duration diff --git a/vendor/google.golang.org/grpc/trace.go b/vendor/google.golang.org/grpc/trace.go index 07a2d26..0a57b99 100644 --- a/vendor/google.golang.org/grpc/trace.go +++ b/vendor/google.golang.org/grpc/trace.go @@ -41,6 +41,9 @@ func methodFamily(m string) string { if i := strings.Index(m, "/"); i >= 0 { m = m[:i] // remove everything from second slash } + if i := strings.LastIndex(m, "."); i >= 0 { + m = m[i+1:] // cut down to last dotted component + } return m } diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index 1a831b1..1d3b043 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@ package grpc // Version is the current grpc version. -const Version = "1.27.1" +const Version = "1.26.0" diff --git a/vendor/google.golang.org/grpc/vet.sh b/vendor/google.golang.org/grpc/vet.sh index 0e73707..798921a 100755 --- a/vendor/google.golang.org/grpc/vet.sh +++ b/vendor/google.golang.org/grpc/vet.sh @@ -81,7 +81,7 @@ fi # - Do not import math/rand for real library code. Use internal/grpcrand for # thread safety. -git grep -l '"math/rand"' -- "*.go" 2>&1 | (! grep -v '^examples\|^stress\|grpcrand\|^benchmark\|wrr_test') +git grep -l '"math/rand"' -- "*.go" 2>&1 | (! grep -v '^examples\|^stress\|grpcrand\|wrr_test') # - Ensure all ptypes proto packages are renamed when importing. (! git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go")