mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Check the indexcoord state before get index state (#12452)
Signed-off-by: Cai.Zhang <cai.zhang@zilliz.com>
This commit is contained in:
parent
b42019256c
commit
961e9379c6
@ -435,6 +435,16 @@ func (i *IndexCoord) BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequ
|
||||
// GetIndexStates gets the index states from IndexCoord.
|
||||
func (i *IndexCoord) GetIndexStates(ctx context.Context, req *indexpb.GetIndexStatesRequest) (*indexpb.GetIndexStatesResponse, error) {
|
||||
log.Debug("IndexCoord get index states", zap.Int64s("IndexBuildIDs", req.IndexBuildIDs))
|
||||
if !i.isHealthy() {
|
||||
errMsg := "IndexCoord is not healthy"
|
||||
log.Warn(errMsg)
|
||||
return &indexpb.GetIndexStatesResponse{
|
||||
Status: &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
||||
Reason: errMsg,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
sp, _ := trace.StartSpanFromContextWithOperationName(ctx, "IndexCoord-BuildIndex")
|
||||
defer sp.Finish()
|
||||
var (
|
||||
|
||||
@ -260,4 +260,9 @@ func TestIndexCoord_NotHealthy(t *testing.T) {
|
||||
status, err := ic.DropIndex(context.Background(), req2)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, status.ErrorCode)
|
||||
|
||||
req3 := &indexpb.GetIndexStatesRequest{}
|
||||
resp2, err := ic.GetIndexStates(context.Background(), req3)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp2.Status.ErrorCode)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user