Skip to content

Commit

Permalink
xdsclient: NACK cluster resource if config_source_specifier in lrs_se…
Browse files Browse the repository at this point in the history
…rver is not self (#5613)
  • Loading branch information
easwars committed Aug 30, 2022
1 parent c351f37 commit d875a0e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
9 changes: 8 additions & 1 deletion xds/internal/xdsclient/xdsresource/unmarshal_cds.go
Expand Up @@ -155,7 +155,14 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu
// xdsclient bootstrap information now (can be added if necessary). The
// ServerConfig will be read and populated by the CDS balancer when
// processing this field.
if cluster.GetLrsServer().GetSelf() != nil {
// According to A27:
// If the `lrs_server` field is set, it must have its `self` field set, in
// which case the client should use LRS for load reporting. Otherwise
// (the `lrs_server` field is not set), LRS load reporting will be disabled.
if lrs := cluster.GetLrsServer(); lrs != nil {
if lrs.GetSelf() == nil {
return ClusterUpdate{}, fmt.Errorf("unsupported config_source_specifier %T in lrs_server field", lrs.ConfigSourceSpecifier)
}
ret.LRSServerConfig = ClusterLRSServerSelf
}

Expand Down
35 changes: 35 additions & 0 deletions xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go
Expand Up @@ -1503,6 +1503,41 @@ func (s) TestUnmarshalCluster(t *testing.T) {
},
wantErr: true,
},
{
name: "cluster resource with non-self lrs_server field",
resources: []*anypb.Any{
testutils.MarshalAny(&v3clusterpb.Cluster{
Name: "test",
ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS},
EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{
EdsConfig: &v3corepb.ConfigSource{
ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{
Ads: &v3corepb.AggregatedConfigSource{},
},
},
ServiceName: v3Service,
},
LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN,
LrsServer: &v3corepb.ConfigSource{
ConfigSourceSpecifier: &v3corepb.ConfigSource_Ads{
Ads: &v3corepb.AggregatedConfigSource{},
},
},
}),
},
wantUpdate: map[string]ClusterUpdateErrTuple{
"test": {Err: cmpopts.AnyError},
},
wantMD: UpdateMetadata{
Status: ServiceStatusNACKed,
Version: testVersion,
ErrState: &UpdateErrorMetadata{
Version: testVersion,
Err: cmpopts.AnyError,
},
},
wantErr: true,
},
{
name: "v2 cluster",
resources: []*anypb.Any{v2ClusterAny},
Expand Down

0 comments on commit d875a0e

Please sign in to comment.