Skip to content

Commit

Permalink
Update protobuf to v1.26.0 needed for opentelemetry
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art committed Jun 18, 2021
1 parent aa90da1 commit aabb4c9
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 42 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
7 changes: 3 additions & 4 deletions pkg/networkservice/common/heal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"sync"
"time"

"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/empty"
"google.golang.org/grpc"

Expand Down Expand Up @@ -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) {
Expand All @@ -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
}
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/networkservice/common/refresh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions pkg/networkservice/common/updatepath/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}
Expand Down
14 changes: 3 additions & 11 deletions pkg/networkservice/common/updatetoken/common.go
Original file line number Diff line number Diff line change
@@ -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
//
Expand All @@ -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"
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions pkg/networkservice/common/updatetoken/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions pkg/registry/chains/proxydns/server_nse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit aabb4c9

Please sign in to comment.