File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
xds/internal/xdsclient/xdsresource Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
23
23
"fmt"
24
24
"net"
25
25
"strconv"
26
+ "strings"
26
27
"time"
27
28
28
29
v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
@@ -173,6 +174,9 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu
173
174
}
174
175
ret .ClusterType = ClusterTypeEDS
175
176
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
+ }
176
180
return ret , nil
177
181
case cluster .GetType () == v3clusterpb .Cluster_LOGICAL_DNS :
178
182
if ! envconfig .XDSAggregateAndDNS {
Original file line number Diff line number Diff line change @@ -1347,6 +1347,23 @@ func (s) TestUnmarshalCluster(t *testing.T) {
1347
1347
Raw : v3ClusterAnyWithEDSConfigSourceSelf ,
1348
1348
},
1349
1349
},
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
+ },
1350
1367
}
1351
1368
for _ , test := range tests {
1352
1369
t .Run (test .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments