mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 10:59:32 +08:00
Fix return too many nodeIDs (#23397)
See also: #23396 Signed-off-by: yangxuan <xuan.yang@zilliz.com>
This commit is contained in:
parent
4a6c2b78a7
commit
d56771b7b7
@ -311,10 +311,10 @@ func (s *Server) tryGetNodesMetrics(ctx context.Context, req *milvuspb.GetMetric
|
||||
}
|
||||
|
||||
func (s *Server) fillReplicaInfo(replica *meta.Replica, withShardNodes bool) (*milvuspb.ReplicaInfo, error) {
|
||||
nodeIDs := typeutil.NewUniqueSet(replica.GetNodes()...)
|
||||
info := &milvuspb.ReplicaInfo{
|
||||
ReplicaID: replica.GetID(),
|
||||
CollectionID: replica.GetCollectionID(),
|
||||
NodeIds: replica.GetNodes(),
|
||||
ResourceGroupName: replica.GetResourceGroup(),
|
||||
NumOutboundNode: s.meta.GetOutgoingNodeNumByReplica(replica),
|
||||
}
|
||||
@ -355,7 +355,8 @@ func (s *Server) fillReplicaInfo(replica *meta.Replica, withShardNodes bool) (*m
|
||||
}
|
||||
return 0, false
|
||||
})
|
||||
shard.NodeIds = append(shard.NodeIds, shardNodes...)
|
||||
nodeIDs.Insert(shardNodes...)
|
||||
shard.NodeIds = nodeIDs.Collect()
|
||||
}
|
||||
info.ShardReplicas = append(info.ShardReplicas, shard)
|
||||
}
|
||||
|
@ -1373,6 +1373,15 @@ func (suite *ServiceSuite) TestGetReplicas() {
|
||||
suite.NoError(err)
|
||||
suite.Equal(commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
||||
suite.EqualValues(suite.replicaNumber[collection], len(resp.Replicas))
|
||||
|
||||
// Test no dup nodeIDs in shardReplica
|
||||
for _, replica := range resp.GetReplicas() {
|
||||
suite.Equal(collection, replica.CollectionID)
|
||||
for _, shardReplica := range replica.GetShardReplicas() {
|
||||
gotNodeIDsSet := typeutil.NewUniqueSet(shardReplica.GetNodeIds()...)
|
||||
suite.Equal(len(shardReplica.GetNodeIds()), gotNodeIDsSet.Len())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test when server is not healthy
|
||||
|
Loading…
Reference in New Issue
Block a user