Check component state before get index files (#13578)

Signed-off-by: Cai.Zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2021-12-17 23:10:42 +08:00 committed by GitHub
parent a0cf85b264
commit 2ef2228ad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -541,6 +541,17 @@ func (i *IndexCoord) DropIndex(ctx context.Context, req *indexpb.DropIndexReques
// GetIndexFilePaths gets the index file paths from IndexCoord.
func (i *IndexCoord) GetIndexFilePaths(ctx context.Context, req *indexpb.GetIndexFilePathsRequest) (*indexpb.GetIndexFilePathsResponse, error) {
log.Debug("IndexCoord GetIndexFilePaths", zap.Int64s("IndexBuildIds", req.IndexBuildIDs))
if !i.isHealthy() {
errMsg := "IndexCoord is not healthy"
log.Warn(errMsg)
return &indexpb.GetIndexFilePathsResponse{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: errMsg,
},
FilePaths: nil,
}, nil
}
sp, _ := trace.StartSpanFromContextWithOperationName(ctx, "IndexCoord-BuildIndex")
defer sp.Finish()
var indexPaths []*indexpb.IndexFilePathInfo

View File

@ -277,4 +277,11 @@ func TestIndexCoord_NotHealthy(t *testing.T) {
resp2, err := ic.GetIndexStates(context.Background(), req3)
assert.Nil(t, err)
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp2.Status.ErrorCode)
req4 := &indexpb.GetIndexFilePathsRequest{
IndexBuildIDs: []UniqueID{1, 2},
}
resp4, err := ic.GetIndexFilePaths(context.Background(), req4)
assert.Nil(t, err)
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp4.Status.ErrorCode)
}