refine err msg about no available node in replica (#24257)

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
wei liu 2023-05-22 16:09:27 +08:00 committed by GitHub
parent 909769f9ca
commit c949efab1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 3 deletions

View File

@ -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)
}

View File

@ -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