block uploader restore implementation

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2026-07-27 14:19:22 +08:00
parent d81b319abf
commit bc596da386
3 changed files with 8 additions and 5 deletions
+4 -1
View File
@@ -121,7 +121,10 @@ func snapshotSource(
return "", 0, errors.Wrapf(err, "Failed to run uploader backup for si %v", source)
}
snap.Tags = make(map[string]string)
if snap.Tags == nil {
snap.Tags = make(map[string]string)
}
snap.Tags[uploader.CBTChangeIDTag] = cbtSource.ChangeID
snap.Tags[uploader.CBTVolumeIDTag] = cbtSource.VolumeID
if snapshotTags != nil {
+1 -1
View File
@@ -155,7 +155,7 @@ func (blkup *blockUploader) Restore(snapshot udmrepo.Snapshot, dest destInfo, bi
}
if len(meta.SubObjects) != 1 {
return 0, errors.Wrapf(err, "unexpected number of bdev object (%d) for snapshot %s", len(meta.SubObjects), snapshot.Description)
return 0, errors.Errorf("unexpected number of bdev object (%d) for snapshot %s", len(meta.SubObjects), snapshot.Description)
}
sourceSize, err := getSourceSize(snapshot)
+3 -3
View File
@@ -483,7 +483,7 @@ func TestGetSourceSize(t *testing.T) {
name: "invalid tag value",
snapshot: udmrepo.Snapshot{
Tags: map[string]string{
"bdev-source-size": "abc",
bdevSourceSizeTag: "abc",
},
},
expectErr: true,
@@ -492,7 +492,7 @@ func TestGetSourceSize(t *testing.T) {
name: "valid tag value",
snapshot: udmrepo.Snapshot{
Tags: map[string]string{
"bdev-source-size": "1048576",
bdevSourceSizeTag: "1048576",
},
},
expectErr: false,
@@ -667,7 +667,7 @@ func TestBlockUploaderRestore(t *testing.T) {
Description: "test snapshot",
RootObject: udmrepo.ObjectMetadata{ID: "root-id"},
Tags: map[string]string{
"bdev-source-size": "1048576",
bdevSourceSizeTag: "1048576",
},
}