Skip to content

Commit

Permalink
Update proto remove omitempty (#373)
Browse files Browse the repository at this point in the history
* Update proto remove omitempty

Signed-off-by: wayblink <[email protected]>

* return schema in GetBackup

Signed-off-by: wayblink <[email protected]>

---------

Signed-off-by: wayblink <[email protected]>
  • Loading branch information
wayblink authored Jul 4, 2024
1 parent 0e539a0 commit 197ad69
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/backup_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func SimpleBackupResponse(input *backuppb.BackupInfoResponse) *backuppb.BackupIn
// clone and remove PartitionBackups, avoid updating here every time we add a field in CollectionBackupInfo
clonedCollectionBackup := proto.Clone(coll).(*backuppb.CollectionBackupInfo)
clonedCollectionBackup.PartitionBackups = nil
clonedCollectionBackup.Schema = nil
// clonedCollectionBackup.Schema = nil // schema is needed by cloud
collections = append(collections, clonedCollectionBackup)
}
simpleBackupInfo := proto.Clone(backup).(*backuppb.BackupInfo)
Expand Down
4 changes: 1 addition & 3 deletions core/backup_meta_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,12 @@ func (meta *MetaManager) GetFullMeta(id string) *backuppb.BackupInfo {
cloneBackup.Size = cloneBackup.Size + collectionBackup.Size
}
cloneBackup.CollectionBackups = collectionBackups
cloneBackup.Progress = 1
if totalSize != 0 {
cloneBackup.Progress = int32(backupedSize * 100 / (totalSize))
} else {
cloneBackup.Progress = 100
}
log.Info("backup progress", zap.Int64("backupedSize", backupedSize), zap.Int64("totalSize", totalSize), zap.Int32("progress", cloneBackup.Progress))

log.Info("Get backup progress", zap.Int64("backupedSize", backupedSize), zap.Int64("totalSize", totalSize), zap.Int32("progress", cloneBackup.Progress))
return cloneBackup
}

Expand Down
20 changes: 10 additions & 10 deletions core/proto/backuppb/backup.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions gen_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ sed -i "" -e "s/has_index,omitempty/has_index/g" ./backuppb/backup.pb.go
sed -i "" -e "s/data,omitempty/data/g" ./backuppb/backup.pb.go
# remove size omitempty
sed -i "" -e "s/size,omitempty/size/g" ./backuppb/backup.pb.go
# remove progress omitempty
sed -i "" -e "s/progress,omitempty/progress/g" ./backuppb/backup.pb.go
# remove state_code omitempty
sed -i "" -e "s/state_code,omitempty/state_code/g" ./backuppb/backup.pb.go

# to make db_collections field compatible to both json and string
#sed -i "" -e "s/*_struct.Value/interface{}/g" ./backuppb/backup.pb.go
Expand Down
4 changes: 4 additions & 0 deletions gen_swag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ sed -i "" -e "s/has_index,omitempty/has_index/g" ./backuppb/backup.pb.go
sed -i "" -e "s/data,omitempty/data/g" ./backuppb/backup.pb.go
# remove size omitempty
sed -i "" -e "s/size,omitempty/size/g" ./backuppb/backup.pb.go
# remove progress omitempty
sed -i "" -e "s/progress,omitempty/progress/g" ./backuppb/backup.pb.go
# remove state_code omitempty
sed -i "" -e "s/state_code,omitempty/state_code/g" ./backuppb/backup.pb.go

popd

Expand Down
4 changes: 2 additions & 2 deletions tests/api/milvus_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def wait_create_backup_complete(self, backup_name, timeout=120):
res = self.get_backup(backup_name)
while not ready and (end_time - start_time < timeout):
state_code = res["data"].get("state_code", 1)
if state_code == 1:
if state_code == 1 or state_code == 0:
time.sleep(5)
res = self.get_backup(backup_name)
end_time = time.time()
Expand All @@ -173,7 +173,7 @@ def wait_restore_complete(self, id, timeout=120):
res = self.get_restore(id)
while not ready and end_time - start_time < timeout:
state_code = res["data"].get("state_code", 1)
if state_code == 1:
if state_code == 1 or state_code == 0:
time.sleep(5)
res = self.get_restore(id)
end_time = time.time()
Expand Down

0 comments on commit 197ad69

Please sign in to comment.