Skip to content

Commit f0280f9

Browse files
authored
xds: require EDS service name in new-style CDS clusters (gRFC A47) (#6438)
1 parent bf5b7ae commit f0280f9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

xds/internal/xdsclient/xdsresource/unmarshal_cds.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"fmt"
2424
"net"
2525
"strconv"
26+
"strings"
2627
"time"
2728

2829
v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
@@ -173,6 +174,9 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu
173174
}
174175
ret.ClusterType = ClusterTypeEDS
175176
ret.EDSServiceName = cluster.GetEdsClusterConfig().GetServiceName()
177+
if strings.HasPrefix(ret.ClusterName, "xdstp:") && ret.EDSServiceName == "" {
178+
return ClusterUpdate{}, fmt.Errorf("CDS's EDS service name is not set with a new-style cluster name: %+v", cluster)
179+
}
176180
return ret, nil
177181
case cluster.GetType() == v3clusterpb.Cluster_LOGICAL_DNS:
178182
if !envconfig.XDSAggregateAndDNS {

xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,23 @@ func (s) TestUnmarshalCluster(t *testing.T) {
13471347
Raw: v3ClusterAnyWithEDSConfigSourceSelf,
13481348
},
13491349
},
1350+
{
1351+
name: "xdstp cluster resource with unset EDS service name",
1352+
resource: testutils.MarshalAny(&v3clusterpb.Cluster{
1353+
Name: "xdstp:foo",
1354+
ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS},
1355+
EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{
1356+
EdsConfig: &v3corepb.ConfigSource{
1357+
ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{
1358+
Ads: &v3corepb.AggregatedConfigSource{},
1359+
},
1360+
},
1361+
ServiceName: "",
1362+
},
1363+
}),
1364+
wantName: "xdstp:foo",
1365+
wantErr: true,
1366+
},
13501367
}
13511368
for _, test := range tests {
13521369
t.Run(test.name, func(t *testing.T) {

0 commit comments

Comments
 (0)