xds: add temporary logging to LRS (#3490)

This commit is contained in:
Menghan Li 2020-04-02 16:55:06 -07:00 committed by GitHub
parent 508cf42036
commit fe1d8e7181
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -313,9 +313,10 @@ func (ls *lrsStore) ReportTo(ctx context.Context, cc *grpc.ClientConn, clusterNa
grpclog.Warningf("lrs: failed to create stream: %v", err) grpclog.Warningf("lrs: failed to create stream: %v", err)
continue continue
} }
if err := stream.Send(&lrspb.LoadStatsRequest{ grpclog.Infof("lrs: created LRS stream")
Node: node, req := &lrspb.LoadStatsRequest{Node: node}
}); err != nil { grpclog.Infof("lrs: sending init LoadStatsRequest: %v", req)
if err := stream.Send(req); err != nil {
grpclog.Warningf("lrs: failed to send first request: %v", err) grpclog.Warningf("lrs: failed to send first request: %v", err)
continue continue
} }
@ -324,6 +325,7 @@ func (ls *lrsStore) ReportTo(ctx context.Context, cc *grpc.ClientConn, clusterNa
grpclog.Warningf("lrs: failed to receive first response: %v", err) grpclog.Warningf("lrs: failed to receive first response: %v", err)
continue continue
} }
grpclog.Infof("lrs: received first LoadStatsResponse: %+v", first)
interval, err := ptypes.Duration(first.LoadReportingInterval) interval, err := ptypes.Duration(first.LoadReportingInterval)
if err != nil { if err != nil {
grpclog.Warningf("lrs: failed to convert report interval: %v", err) grpclog.Warningf("lrs: failed to convert report interval: %v", err)
@ -366,9 +368,9 @@ func (ls *lrsStore) sendLoads(ctx context.Context, stream lrsgrpc.LoadReportingS
case <-ctx.Done(): case <-ctx.Done():
return return
} }
if err := stream.Send(&lrspb.LoadStatsRequest{ req := &lrspb.LoadStatsRequest{ClusterStats: ls.buildStats(clusterName)}
ClusterStats: ls.buildStats(clusterName), grpclog.Infof("lrs: sending LRS loads: %+v", req)
}); err != nil { if err := stream.Send(req); err != nil {
grpclog.Warningf("lrs: failed to send report: %v", err) grpclog.Warningf("lrs: failed to send report: %v", err)
return return
} }

View File

@ -44,9 +44,11 @@ func (c *Client) ReportLoad(server string, clusterName string, loadStore lrs.Sto
cc *grpc.ClientConn cc *grpc.ClientConn
closeCC bool closeCC bool
) )
c.logger.Infof("Starting load report to server: %s", server)
if server == "" || server == c.opts.Config.BalancerName { if server == "" || server == c.opts.Config.BalancerName {
cc = c.cc cc = c.cc
} else { } else {
c.logger.Infof("LRS server is different from xDS server, starting a new ClientConn")
dopts := append([]grpc.DialOption{c.opts.Config.Creds}, c.opts.DialOpts...) dopts := append([]grpc.DialOption{c.opts.Config.Creds}, c.opts.DialOpts...)
ccNew, err := grpc.Dial(server, dopts...) ccNew, err := grpc.Dial(server, dopts...)
if err != nil { if err != nil {