mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
refine err msg about no available node in replica (#24257)
Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
parent
909769f9ca
commit
c949efab1f
@ -837,13 +837,23 @@ func (s *Server) GetReplicas(ctx context.Context, req *milvuspb.GetReplicasReque
|
||||
}
|
||||
|
||||
for _, replica := range replicas {
|
||||
info, err := s.fillReplicaInfo(replica, req.GetWithShardNodes())
|
||||
if err != nil {
|
||||
msg := "failed to get replica info"
|
||||
msg := "failed to get replica info"
|
||||
if len(replica.GetNodes()) == 0 {
|
||||
err := fmt.Errorf("replica=%d: no available node in replica", replica.ID)
|
||||
log.Warn(msg,
|
||||
zap.Int64("replica", replica.GetID()),
|
||||
zap.Error(err))
|
||||
resp.Status = utils.WrapStatus(commonpb.ErrorCode_MetaFailed, msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
info, err := s.fillReplicaInfo(replica, req.GetWithShardNodes())
|
||||
if err != nil {
|
||||
log.Warn(msg,
|
||||
zap.Int64("replica", replica.GetID()),
|
||||
zap.Error(err))
|
||||
resp.Status = utils.WrapStatus(commonpb.ErrorCode_MetaFailed, msg, err)
|
||||
break
|
||||
}
|
||||
resp.Replicas = append(resp.Replicas, info)
|
||||
}
|
||||
|
||||
@ -1483,6 +1483,24 @@ func (suite *ServiceSuite) TestGetReplicas() {
|
||||
suite.Equal(commonpb.ErrorCode_NotReadyServe, resp.GetStatus().GetErrorCode())
|
||||
}
|
||||
|
||||
func (suite *ServiceSuite) TestGetReplicasFailed() {
|
||||
suite.loadAll()
|
||||
ctx := context.Background()
|
||||
server := suite.server
|
||||
|
||||
suite.meta.ReplicaManager.Put(utils.CreateTestReplica(100001, 100000, []int64{}))
|
||||
suite.meta.ReplicaManager.Put(utils.CreateTestReplica(100002, 100000, []int64{1}))
|
||||
|
||||
req := &milvuspb.GetReplicasRequest{
|
||||
CollectionID: 100000,
|
||||
WithShardNodes: true,
|
||||
}
|
||||
resp, err := server.GetReplicas(ctx, req)
|
||||
suite.NoError(err)
|
||||
suite.Equal(commonpb.ErrorCode_MetaFailed, resp.GetStatus().GetErrorCode())
|
||||
suite.EqualValues(resp.GetStatus().GetReason(), "failed to get replica info, err=replica=100001: no available node in replica")
|
||||
}
|
||||
|
||||
func (suite *ServiceSuite) TestCheckHealth() {
|
||||
ctx := context.Background()
|
||||
server := suite.server
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user