From aabb4c925e702c636a4886e16f88a48edb3fd3df Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Fri, 18 Jun 2021 15:59:40 +0700 Subject: [PATCH] Update protobuf to v1.26.0 needed for opentelemetry Signed-off-by: Artem Glazychev --- go.mod | 6 +++--- go.sum | 12 ++++++++---- pkg/networkservice/common/heal/server.go | 7 +++---- pkg/networkservice/common/refresh/client.go | 5 ++--- pkg/networkservice/common/updatepath/server.go | 13 ++----------- pkg/networkservice/common/updatetoken/common.go | 14 +++----------- .../common/updatetoken/server_test.go | 4 ++-- pkg/registry/chains/proxydns/server_nse_test.go | 8 ++++---- 8 files changed, 27 insertions(+), 42 deletions(-) diff --git a/go.mod b/go.mod index c38471f4dc..f7f6f843f3 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/edwarnicke/serialize v1.0.7 github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 - github.com/golang/protobuf v1.4.3 - github.com/google/go-cmp v0.5.2 + github.com/golang/protobuf v1.5.2 + github.com/google/go-cmp v0.5.5 github.com/google/uuid v1.1.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/nats-io/nats-streaming-server v0.17.0 @@ -34,5 +34,5 @@ require ( golang.org/x/tools v0.1.2 // indirect gonum.org/v1/gonum v0.6.2 google.golang.org/grpc v1.35.0 - google.golang.org/protobuf v1.25.0 + google.golang.org/protobuf v1.26.0 ) diff --git a/go.sum b/go.sum index e51535a16e..73cb0deafb 100644 --- a/go.sum +++ b/go.sum @@ -68,15 +68,17 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -299,8 +301,10 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= diff --git a/pkg/networkservice/common/heal/server.go b/pkg/networkservice/common/heal/server.go index 1e5743e982..154dc9de98 100644 --- a/pkg/networkservice/common/heal/server.go +++ b/pkg/networkservice/common/heal/server.go @@ -24,7 +24,6 @@ import ( "sync" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" "google.golang.org/grpc" @@ -193,10 +192,10 @@ func (f *healServer) restoreConnection(ctx context.Context, request *networkserv // Make sure we have a valid expireTime to work with expires := request.GetConnection().GetNextPathSegment().GetExpires() - expireTime, err := ptypes.Timestamp(expires) - if err != nil { + if !expires.IsValid() { return } + expireTime := expires.AsTime() deadline := clockTime.Now().Add(f.restoreTimeout) if deadline.After(expireTime) { @@ -206,7 +205,7 @@ func (f *healServer) restoreConnection(ctx context.Context, request *networkserv defer requestCancel() for requestCtx.Err() == nil { - if _, err = (*f.onHeal).Request(requestCtx, request.Clone(), opts...); err == nil { + if _, err := (*f.onHeal).Request(requestCtx, request.Clone(), opts...); err == nil { return } } diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index e998fa1609..c2869d42ce 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -25,7 +25,6 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" "google.golang.org/grpc" @@ -83,10 +82,10 @@ func (t *refreshClient) startTimer(ctx context.Context, connectionID string, req clockTime := clock.FromContext(ctx) nextClient := next.Client(ctx) - expireTime, err := ptypes.Timestamp(request.GetConnection().GetCurrentPathSegment().GetExpires()) - if err != nil { + if !request.GetConnection().GetCurrentPathSegment().GetExpires().IsValid() { return } + expireTime := request.GetConnection().GetCurrentPathSegment().GetExpires().AsTime() // A heuristic to reduce the number of redundant requests in a chain // made of refreshing clients with the same expiration time: let outer diff --git a/pkg/networkservice/common/updatepath/server.go b/pkg/networkservice/common/updatepath/server.go index 1dd4a2e138..4ebfc29346 100644 --- a/pkg/networkservice/common/updatepath/server.go +++ b/pkg/networkservice/common/updatepath/server.go @@ -23,12 +23,9 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" - "github.com/golang/protobuf/ptypes/timestamp" - "github.com/pkg/errors" - "github.com/networkservicemesh/api/pkg/api/networkservice" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" "github.com/networkservicemesh/sdk/pkg/tools/log" @@ -66,13 +63,7 @@ func (i *updatePathServer) Request(ctx context.Context, request *networkservice. if err != nil { log.FromContext(ctx).Warnf("an error during getting token from the context: %+v", err) } else { - var expires *timestamp.Timestamp - expires, err = ptypes.TimestampProto(expireTime.Local()) - if err != nil { - return nil, errors.WithStack(err) - } - - prev.Expires = expires + prev.Expires = timestamppb.New(expireTime.Local()) prev.Token = tok } } diff --git a/pkg/networkservice/common/updatetoken/common.go b/pkg/networkservice/common/updatetoken/common.go index 4dc6f4414f..d7e56af98a 100644 --- a/pkg/networkservice/common/updatetoken/common.go +++ b/pkg/networkservice/common/updatetoken/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2020-2021 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -19,9 +19,8 @@ package updatetoken import ( "context" - "github.com/golang/protobuf/ptypes/timestamp" + "google.golang.org/protobuf/types/known/timestamppb" - "github.com/golang/protobuf/ptypes" "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/pkg/errors" "google.golang.org/grpc/credentials" @@ -51,15 +50,8 @@ func updateToken(ctx context.Context, conn *networkservice.Connection, tokenGene return errors.WithStack(err) } - // Convert the expireTime to proto - var expires *timestamp.Timestamp - expires, err = ptypes.TimestampProto(expireTime) - if err != nil { - return errors.WithStack(err) - } - // Update the PathSegment path.GetPathSegments()[path.GetIndex()].Token = tok - path.GetPathSegments()[path.GetIndex()].Expires = expires + path.GetPathSegments()[path.GetIndex()].Expires = timestamppb.New(expireTime) return nil } diff --git a/pkg/networkservice/common/updatetoken/server_test.go b/pkg/networkservice/common/updatetoken/server_test.go index 58b7048594..577e8f8634 100644 --- a/pkg/networkservice/common/updatetoken/server_test.go +++ b/pkg/networkservice/common/updatetoken/server_test.go @@ -32,10 +32,10 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/common/updatetoken" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/timestamp" "go.uber.org/goleak" "google.golang.org/grpc/credentials" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/stretchr/testify/assert" @@ -55,7 +55,7 @@ type updateTokenServerSuite struct { func (f *updateTokenServerSuite) SetupSuite() { f.Token, f.Expires, _ = TokenGenerator(nil) - f.ExpiresProto, _ = ptypes.TimestampProto(f.Expires) + f.ExpiresProto = timestamppb.New(f.Expires) } func (f *updateTokenServerSuite) TestNewServer_EmptyPathInRequest() { diff --git a/pkg/registry/chains/proxydns/server_nse_test.go b/pkg/registry/chains/proxydns/server_nse_test.go index 07c07add8a..268ff11a08 100644 --- a/pkg/registry/chains/proxydns/server_nse_test.go +++ b/pkg/registry/chains/proxydns/server_nse_test.go @@ -22,10 +22,10 @@ import ( "testing" "time" - "github.com/golang/protobuf/ptypes" "github.com/stretchr/testify/require" "go.uber.org/goleak" "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/timestamppb" registryapi "github.com/networkservicemesh/api/pkg/api/registry" @@ -70,7 +70,7 @@ func TestInterdomainNetworkServiceEndpointRegistry(t *testing.T) { SetDNSDomainName("domain2"). Build() - expirationTime, _ := ptypes.TimestampProto(time.Now().Add(time.Hour)) + expirationTime := timestamppb.New(time.Now().Add(time.Hour)) reg, err := domain2.Registry.NetworkServiceEndpointRegistryServer().Register( context.Background(), @@ -135,7 +135,7 @@ func TestLocalDomain_NetworkServiceEndpointRegistry(t *testing.T) { SetDNSResolver(dnsServer). Build() - expirationTime, _ := ptypes.TimestampProto(time.Now().Add(time.Hour)) + expirationTime := timestamppb.New(time.Now().Add(time.Hour)) reg, err := domain1.Registry.NetworkServiceEndpointRegistryServer().Register( context.Background(), @@ -214,7 +214,7 @@ func TestInterdomainFloatingNetworkServiceEndpointRegistry(t *testing.T) { SetDNSDomainName("floating.domain"). Build() - expirationTime, _ := ptypes.TimestampProto(time.Now().Add(time.Hour)) + expirationTime := timestamppb.New(time.Now().Add(time.Hour)) reg, err := domain2.Registry.NetworkServiceEndpointRegistryServer().Register( context.Background(),