Skip to content

Commit

Permalink
xds: require EDS service name in new-style CDS clusters (gRFC A47) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Jul 11, 2023
1 parent bf5b7ae commit f0280f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xds/internal/xdsclient/xdsresource/unmarshal_cds.go
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"net"
"strconv"
"strings"
"time"

v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
Expand Down Expand Up @@ -173,6 +174,9 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu
}
ret.ClusterType = ClusterTypeEDS
ret.EDSServiceName = cluster.GetEdsClusterConfig().GetServiceName()
if strings.HasPrefix(ret.ClusterName, "xdstp:") && ret.EDSServiceName == "" {
return ClusterUpdate{}, fmt.Errorf("CDS's EDS service name is not set with a new-style cluster name: %+v", cluster)
}
return ret, nil
case cluster.GetType() == v3clusterpb.Cluster_LOGICAL_DNS:
if !envconfig.XDSAggregateAndDNS {
Expand Down
17 changes: 17 additions & 0 deletions xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go
Expand Up @@ -1347,6 +1347,23 @@ func (s) TestUnmarshalCluster(t *testing.T) {
Raw: v3ClusterAnyWithEDSConfigSourceSelf,
},
},
{
name: "xdstp cluster resource with unset EDS service name",
resource: testutils.MarshalAny(&v3clusterpb.Cluster{
Name: "xdstp:foo",
ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS},
EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{
EdsConfig: &v3corepb.ConfigSource{
ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{
Ads: &v3corepb.AggregatedConfigSource{},
},
},
ServiceName: "",
},
}),
wantName: "xdstp:foo",
wantErr: true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down

0 comments on commit f0280f9

Please sign in to comment.