fix: fix hasCollection response has no status (#37254)

issue: #37257

Signed-off-by: wayblink <anyang.wang@zilliz.com>
This commit is contained in:
wayblink 2024-11-01 15:40:21 +08:00 committed by GitHub
parent be71b98146
commit d119a2541a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -565,10 +565,13 @@ func (t *hasCollectionTask) PreExecute(ctx context.Context) error {
}
func (t *hasCollectionTask) Execute(ctx context.Context) error {
t.result = &milvuspb.BoolResponse{
Status: merr.Success(),
}
_, err := globalMetaCache.GetCollectionID(ctx, t.HasCollectionRequest.GetDbName(), t.HasCollectionRequest.GetCollectionName())
t.result = &milvuspb.BoolResponse{}
// error other than
if err != nil && !errors.Is(err, merr.ErrCollectionNotFound) {
t.result.Status = merr.Status(err)
return err
}
// if collection not nil, means error is ErrCollectionNotFound, result is false

View File

@ -1095,6 +1095,7 @@ func TestHasCollectionTask(t *testing.T) {
err = task.Execute(ctx)
assert.NoError(t, err)
assert.False(t, task.result.GetValue())
assert.NotNil(t, task.result.GetStatus())
// rootcoord failed to get response
rc.updateState(commonpb.StateCode_Abnormal)