mirror of https://github.com/milvus-io/milvus.git
Print collectionName when load failed (#16878)
Signed-off-by: xige-16 <xi.ge@zilliz.com>pull/16910/head
parent
be688d894a
commit
9e6d9fb7d8
|
@ -1311,7 +1311,12 @@ func (sct *showCollectionsTask) Execute(ctx context.Context) error {
|
|||
}
|
||||
|
||||
if resp.Status.ErrorCode != commonpb.ErrorCode_Success {
|
||||
return errors.New(resp.Status.Reason)
|
||||
// update collectionID to collection name, and return new error info to sdk
|
||||
newErrorReason := resp.Status.Reason
|
||||
for _, collectionID := range collectionIDs {
|
||||
newErrorReason = ReplaceID2Name(newErrorReason, collectionID, IDs2Names[collectionID])
|
||||
}
|
||||
return errors.New(newErrorReason)
|
||||
}
|
||||
|
||||
sct.result = &milvuspb.ShowCollectionsResponse{
|
||||
|
|
|
@ -555,3 +555,7 @@ func ValidatePassword(password string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReplaceID2Name(oldStr string, id int64, name string) string {
|
||||
return strings.ReplaceAll(oldStr, strconv.FormatInt(id, 10), name)
|
||||
}
|
||||
|
|
|
@ -610,3 +610,9 @@ func TestValidatePassword(t *testing.T) {
|
|||
res = ValidatePassword("aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmnnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrsssssssssstttttttttttuuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwwxxxxxxxxxxyyyyyyyyyzzzzzzzzzzz")
|
||||
assert.Error(t, res)
|
||||
}
|
||||
|
||||
func TestReplaceID2Name(t *testing.T) {
|
||||
srcStr := "collection 432682805904801793 has not been loaded to memory or load failed"
|
||||
dstStr := "collection default_collection has not been loaded to memory or load failed"
|
||||
assert.Equal(t, dstStr, ReplaceID2Name(srcStr, int64(432682805904801793), "default_collection"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue