mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-01 04:46:05 +00:00
block uploader backup implementation
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
Copyright the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package kopialib
|
||||
|
||||
import (
|
||||
|
||||
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -99,7 +99,7 @@ func (bu *blockUploader) Backup(source sourceInfo, parentObject udmrepo.ID, bitm
|
||||
|
||||
id, backupSize, objectSize, err := bu.backupObject(source.dev, destObj, bitmap, source.size)
|
||||
if err != nil {
|
||||
return udmrepo.Snapshot{}, 0, errors.Wrap(err, "error to backup file with incremental")
|
||||
return udmrepo.Snapshot{}, 0, errors.Wrapf(err, "error backing up bdev %s", source.realSource)
|
||||
}
|
||||
|
||||
entryId, err := bu.repoWriter.WriteMetadata(bu.ctx, &udmrepo.Metadata{
|
||||
@@ -117,7 +117,7 @@ func (bu *blockUploader) Backup(source sourceInfo, parentObject udmrepo.ID, bitm
|
||||
Description: "bdev-root",
|
||||
})
|
||||
if err != nil {
|
||||
return udmrepo.Snapshot{}, 0, errors.Wrap(err, "error to write metadata")
|
||||
return udmrepo.Snapshot{}, 0, errors.Wrap(err, "error writing metadata")
|
||||
}
|
||||
|
||||
snapEnd := bu.repoWriter.Time()
|
||||
@@ -139,13 +139,13 @@ func (bu *blockUploader) Backup(source sourceInfo, parentObject udmrepo.ID, bitm
|
||||
|
||||
// TODO implement in following PRs
|
||||
func (bu *blockUploader) Restore(snapshot udmrepo.Snapshot, dest destInfo, bitmap cbt.Iterator, configs map[string]string) (int64, error) {
|
||||
return 0, nil
|
||||
return 0, errors.New("not implemented")
|
||||
}
|
||||
|
||||
func (bu *blockUploader) backupObject(dev *os.File, dest udmrepo.ObjectWriter, bitmap cbt.Iterator, totalLength int64) (udmrepo.ID, int64, int64, error) {
|
||||
backupSize, objectSize, err := bu.backupData(dev, dest, bitmap, totalLength)
|
||||
if err != nil {
|
||||
return "", backupSize, objectSize, errors.Wrap(err, "error copying file data incremental")
|
||||
return "", backupSize, objectSize, err
|
||||
}
|
||||
|
||||
id, err := dest.Result()
|
||||
|
||||
@@ -75,7 +75,7 @@ func TestGetObjectName(t *testing.T) {
|
||||
{
|
||||
name: "unix path",
|
||||
source: "/var/lib/kubelet/pods/uuid/volumes/test",
|
||||
expected: "-var-lib-kubelet-pods-uuid-volumes-test",
|
||||
expected: "var-lib-kubelet-pods-uuid-volumes-test",
|
||||
},
|
||||
{
|
||||
name: "windows path",
|
||||
@@ -196,7 +196,7 @@ func TestBlockUploaderBackup(t *testing.T) {
|
||||
name: "canceled in progress",
|
||||
cancelInProgress: true,
|
||||
expectErr: true,
|
||||
expectErrStr: "error copying file data incremental: uploader is canceled",
|
||||
expectErrStr: "error backing up bdev /data/volume1: uploader is canceled",
|
||||
},
|
||||
{
|
||||
name: "create object writer err",
|
||||
@@ -357,7 +357,7 @@ func TestBlockUploaderBackup(t *testing.T) {
|
||||
}
|
||||
|
||||
repoWriter.On("NewObjectWriter", mock.Anything, mock.MatchedBy(func(opt udmrepo.ObjectWriteOptions) bool {
|
||||
return opt.Description == "BDEV:-data-volume1" && opt.BackupMode == backupMode
|
||||
return opt.Description == "BDEV:data-volume1" && opt.BackupMode == backupMode
|
||||
})).Return(objWriter, tc.createObjErr)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user