mirror of https://github.com/grpc/grpc-go.git
xds/internal/xdsclient: NACK empty clusters in aggregate clusters (#6023)
This commit is contained in:
parent
081499f2e8
commit
30d8c0a043
|
|
@ -177,6 +177,9 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu
|
|||
if err := proto.Unmarshal(cluster.GetClusterType().GetTypedConfig().GetValue(), clusters); err != nil {
|
||||
return ClusterUpdate{}, fmt.Errorf("failed to unmarshal resource: %v", err)
|
||||
}
|
||||
if len(clusters.Clusters) == 0 {
|
||||
return ClusterUpdate{}, fmt.Errorf("xds: aggregate cluster has empty clusters field in response: %+v", cluster)
|
||||
}
|
||||
ret.ClusterType = ClusterTypeAggregate
|
||||
ret.PrioritizedClusterNames = clusters.Clusters
|
||||
return ret, nil
|
||||
|
|
|
|||
|
|
@ -194,6 +194,38 @@ func (s) TestValidateCluster_Failure(t *testing.T) {
|
|||
wantUpdate: emptyUpdate,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "aggregate-nil-clusters",
|
||||
cluster: &v3clusterpb.Cluster{
|
||||
Name: clusterName,
|
||||
ClusterDiscoveryType: &v3clusterpb.Cluster_ClusterType{
|
||||
ClusterType: &v3clusterpb.Cluster_CustomClusterType{
|
||||
Name: "envoy.clusters.aggregate",
|
||||
TypedConfig: testutils.MarshalAny(&v3aggregateclusterpb.ClusterConfig{}),
|
||||
},
|
||||
},
|
||||
LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN,
|
||||
},
|
||||
wantUpdate: emptyUpdate,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "aggregate-empty-clusters",
|
||||
cluster: &v3clusterpb.Cluster{
|
||||
Name: clusterName,
|
||||
ClusterDiscoveryType: &v3clusterpb.Cluster_ClusterType{
|
||||
ClusterType: &v3clusterpb.Cluster_CustomClusterType{
|
||||
Name: "envoy.clusters.aggregate",
|
||||
TypedConfig: testutils.MarshalAny(&v3aggregateclusterpb.ClusterConfig{
|
||||
Clusters: []string{},
|
||||
}),
|
||||
},
|
||||
},
|
||||
LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN,
|
||||
},
|
||||
wantUpdate: emptyUpdate,
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
oldAggregateAndDNSSupportEnv := envconfig.XDSAggregateAndDNS
|
||||
|
|
|
|||
Loading…
Reference in New Issue