Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds: require EDS service name in new-style CDS clusters (gRFC A47) #6438

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
xds: require EDS service name to be set in a CDS cluster with an 'xds…
…tp' resource name (gRFC A47)
  • Loading branch information
dfawley committed Jul 10, 2023
commit 9e51e5760a466952948dc57941b061e759ff2877
4 changes: 4 additions & 0 deletions xds/internal/xdsclient/xdsresource/unmarshal_cds.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be xdstp:///foo? I understand it doesn't matter for the purpose of this unit test. But was just curious if xdstp:foo was a valid name at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two are equivalent under RFC 3986 parsing.

Also I took it from the test case in C without really thinking too hard about it. 😆

I'm not sure what does or should happen in this case, though. Does/should it just not work? Does/should it use the channel's default authority? Does/should it use the authority for the CDS resource?

The only meaningful thing this cluster.name field seems to do for us is this:

https://github.com/grpc/grpc-go/blob/bf5b7aecd53ba679d72d43bbf61dee40633f6344/xds/internal/balancer/cdsbalancer/cdsbalancer.go#L338C4-L344

Looks like we'd just ignore it (or use the default authority?) to determine the load reporting server. I'm not sure if that's right or not, TBH - do you have any intuition about it?

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