Skip to content

Commit

Permalink
[c2p_id_random] c2p: add random number to xDS node ID in google-c2p r…
Browse files Browse the repository at this point in the history
…esolver
  • Loading branch information
menghanl committed Jun 4, 2021
1 parent 656cad9 commit 39cc18a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion xds/googledirectpath/googlec2p.go
Expand Up @@ -27,6 +27,7 @@ package googledirectpath

import (
"fmt"
"math/rand"
"time"

v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
Expand Down Expand Up @@ -152,13 +153,15 @@ var ipv6EnabledMetadata = &structpb.Struct{
},
}

var id = fmt.Sprintf("C2P-%d", rand.Int())

// newNode makes a copy of defaultNode, and populate it's Metadata and
// Locality fields.
func newNode(zone string, ipv6Capable bool) *v3corepb.Node {
ret := &v3corepb.Node{
// Not all required fields are set in defaultNote. Metadata will be set
// if ipv6 is enabled. Locality will be set to the value from metadata.
Id: "C2P",
Id: id,
UserAgentName: gRPCUserAgentName,
UserAgentVersionType: &v3corepb.Node_UserAgentVersion{UserAgentVersion: grpc.Version},
ClientFeatures: []string{clientFeatureNoOverprovisioning},
Expand Down
2 changes: 1 addition & 1 deletion xds/googledirectpath/googlec2p_test.go
Expand Up @@ -194,7 +194,7 @@ func TestBuildXDS(t *testing.T) {
}

wantNode := &v3corepb.Node{
Id: "C2P",
Id: id,
Metadata: nil,
Locality: &v3corepb.Locality{Zone: testZone},
UserAgentName: gRPCUserAgentName,
Expand Down

0 comments on commit 39cc18a

Please sign in to comment.