Skip to content

Commit 39cc18a

Browse files
committed
[c2p_id_random] c2p: add random number to xDS node ID in google-c2p resolver
1 parent 656cad9 commit 39cc18a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

xds/googledirectpath/googlec2p.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ package googledirectpath
2727

2828
import (
2929
"fmt"
30+
"math/rand"
3031
"time"
3132

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

156+
var id = fmt.Sprintf("C2P-%d", rand.Int())
157+
155158
// newNode makes a copy of defaultNode, and populate it's Metadata and
156159
// Locality fields.
157160
func newNode(zone string, ipv6Capable bool) *v3corepb.Node {
158161
ret := &v3corepb.Node{
159162
// Not all required fields are set in defaultNote. Metadata will be set
160163
// if ipv6 is enabled. Locality will be set to the value from metadata.
161-
Id: "C2P",
164+
Id: id,
162165
UserAgentName: gRPCUserAgentName,
163166
UserAgentVersionType: &v3corepb.Node_UserAgentVersion{UserAgentVersion: grpc.Version},
164167
ClientFeatures: []string{clientFeatureNoOverprovisioning},

xds/googledirectpath/googlec2p_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestBuildXDS(t *testing.T) {
194194
}
195195

196196
wantNode := &v3corepb.Node{
197-
Id: "C2P",
197+
Id: id,
198198
Metadata: nil,
199199
Locality: &v3corepb.Locality{Zone: testZone},
200200
UserAgentName: gRPCUserAgentName,

0 commit comments

Comments
 (0)