Skip to content

Commit

Permalink
Make it compatible for old milvus without database support
Browse files Browse the repository at this point in the history
  • Loading branch information
wayblink committed Jul 17, 2024
1 parent 382b311 commit 2fb3f76
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions core/backup_impl_create_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,31 @@ func (b *BackupContext) parseBackupCollections(request *backuppb.CreateBackupReq
if request.GetCollectionNames() == nil || len(request.GetCollectionNames()) == 0 {
dbs, err := b.getMilvusClient().ListDatabases(b.ctx)
if err != nil {
log.Error("fail in ListDatabases", zap.Error(err))
return nil, err
}
for _, db := range dbs {
collections, err := b.getMilvusClient().ListCollections(b.ctx, db.Name)
if err != nil {
log.Error("fail in ListCollections", zap.Error(err))
// compatible to milvus under v2.2.8 without database support
if strings.Contains(err.Error(), "feature not supported") {
// default database only
collections, err := b.getMilvusClient().ListCollections(b.ctx, "default")
if err != nil {
log.Error("fail in ListCollections", zap.Error(err))
return nil, err
}
for _, coll := range collections {
toBackupCollections = append(toBackupCollections, collectionStruct{"default", coll.Name})
}
} else {
log.Error("fail in ListDatabases", zap.Error(err))
return nil, err
}
for _, coll := range collections {
toBackupCollections = append(toBackupCollections, collectionStruct{db.Name, coll.Name})
} else {
for _, db := range dbs {
collections, err := b.getMilvusClient().ListCollections(b.ctx, db.Name)
if err != nil {
log.Error("fail in ListCollections", zap.Error(err))
return nil, err
}
for _, coll := range collections {
toBackupCollections = append(toBackupCollections, collectionStruct{db.Name, coll.Name})
}
}
}
log.Debug(fmt.Sprintf("List %v collections", len(toBackupCollections)))
Expand Down

0 comments on commit 2fb3f76

Please sign in to comment.