mirror of https://github.com/milvus-io/milvus.git
Check the indexcoord state before building index (#12451)
Signed-off-by: Cai.Zhang <cai.zhang@zilliz.com>pull/12666/head
parent
567c657310
commit
ed546d0a55
|
@ -361,6 +361,17 @@ func (i *IndexCoord) BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequ
|
|||
zap.Strings("DataPath = ", req.DataPaths),
|
||||
zap.Any("TypeParams", req.TypeParams),
|
||||
zap.Any("IndexParams", req.IndexParams))
|
||||
if !i.isHealthy() {
|
||||
errMsg := "IndexCoord is not healthy"
|
||||
err := errors.New(errMsg)
|
||||
log.Warn(errMsg)
|
||||
return &indexpb.BuildIndexResponse{
|
||||
Status: &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
||||
Reason: errMsg,
|
||||
},
|
||||
}, err
|
||||
}
|
||||
sp, ctx := trace.StartSpanFromContextWithOperationName(ctx, "IndexCoord-BuildIndex")
|
||||
defer sp.Finish()
|
||||
hasIndex, indexBuildID := i.metaTable.HasSameReq(req)
|
||||
|
|
|
@ -247,3 +247,12 @@ func TestIndexCoord_GetComponentStates(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
||||
}
|
||||
|
||||
func TestIndexCoord_NotHealthy(t *testing.T) {
|
||||
ic := &IndexCoord{}
|
||||
ic.stateCode.Store(internalpb.StateCode_Abnormal)
|
||||
req := &indexpb.BuildIndexRequest{}
|
||||
resp, err := ic.BuildIndex(context.Background(), req)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.Status.ErrorCode)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue