xds: LRS handle response contains multiple cluster names (#3393)
- The LRS client will find known clusters from the response, and send the loads - The LRS client support only one cluster now, will be extended to support multiple
This commit is contained in:
@ -332,12 +332,19 @@ func (ls *lrsStore) ReportTo(ctx context.Context, cc *grpc.ClientConn, clusterNa
|
||||
grpclog.Warningf("lrs: failed to convert report interval: %v", err)
|
||||
continue
|
||||
}
|
||||
if len(first.Clusters) != 1 {
|
||||
grpclog.Warningf("lrs: received multiple clusters %v, expect one cluster", first.Clusters)
|
||||
continue
|
||||
// The LRS client should join the clusters it knows with the cluster
|
||||
// list from response, and send loads for them.
|
||||
//
|
||||
// But the LRS client now only supports one cluster. TODO: extend it to
|
||||
// support multiple clusters.
|
||||
var clusterFoundInResponse bool
|
||||
for _, c := range first.Clusters {
|
||||
if c == clusterName {
|
||||
clusterFoundInResponse = true
|
||||
}
|
||||
}
|
||||
if first.Clusters[0] != clusterName {
|
||||
grpclog.Warningf("lrs: received cluster is unexpected. Got %v, want %v", first.Clusters[0], clusterName)
|
||||
if !clusterFoundInResponse {
|
||||
grpclog.Warningf("lrs: received clusters %v does not contain expected {%v}", first.Clusters, clusterName)
|
||||
continue
|
||||
}
|
||||
if first.ReportEndpointGranularity {
|
||||
|
@ -367,7 +367,7 @@ func (lrss *lrsServer) StreamLoadStats(stream lrsgrpc.LoadReportingService_Strea
|
||||
return status.Errorf(codes.FailedPrecondition, "unexpected req: %+v", req)
|
||||
}
|
||||
if err := stream.Send(&lrspb.LoadStatsResponse{
|
||||
Clusters: []string{testService},
|
||||
Clusters: []string{testService, "another-cluster"},
|
||||
LoadReportingInterval: lrss.reportingInterval,
|
||||
}); err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user