From cf730f6fcdc45ba2a7f1e324df57c63dcef147d3 Mon Sep 17 00:00:00 2001 From: Jiquan Long Date: Fri, 19 Aug 2022 11:44:50 +0800 Subject: [PATCH] Fix query cluster metrics (#18725) Signed-off-by: longjiquan Signed-off-by: longjiquan --- internal/querycoord/cluster.go | 13 ++++++++----- internal/querycoord/metrics_info.go | 5 ++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/querycoord/cluster.go b/internal/querycoord/cluster.go index 2341a960ed..4d1014f423 100644 --- a/internal/querycoord/cluster.go +++ b/internal/querycoord/cluster.go @@ -460,8 +460,9 @@ func (c *queryNodeCluster) SyncReplicaSegments(ctx context.Context, leaderID Uni } type queryNodeGetMetricsResponse struct { - resp *milvuspb.GetMetricsResponse - err error + resp *milvuspb.GetMetricsResponse + err error + nodeID UniqueID // used when error occurred. } func (c *queryNodeCluster) GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest) []queryNodeGetMetricsResponse { @@ -470,13 +471,15 @@ func (c *queryNodeCluster) GetMetrics(ctx context.Context, in *milvuspb.GetMetri cnt := len(c.nodes) wg.Add(cnt) respChan := make(chan queryNodeGetMetricsResponse, cnt) - for _, node := range c.nodes { + for nodeID, node := range c.nodes { + nodeID := nodeID go func(node Node) { defer wg.Done() resp, err := node.getMetrics(ctx, in) respChan <- queryNodeGetMetricsResponse{ - resp: resp, - err: err, + resp: resp, + err: err, + nodeID: nodeID, } }(node) } diff --git a/internal/querycoord/metrics_info.go b/internal/querycoord/metrics_info.go index c9704a2fa3..63b5cd8b7a 100644 --- a/internal/querycoord/metrics_info.go +++ b/internal/querycoord/metrics_info.go @@ -98,9 +98,8 @@ func getSystemInfoMetrics( BaseComponentInfos: metricsinfo.BaseComponentInfos{ HasError: true, ErrorReason: nodeMetrics.err.Error(), - // Name doesn't matter here because we can't get it when error occurs, using address as the Name? - Name: "", - ID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()), + Name: metricsinfo.ConstructComponentName(typeutil.QueryNodeRole, nodeMetrics.nodeID), + ID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()), }, }) continue