mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-10-01 04:05:38 +00:00
fix(uploader): align block and kopia snapshot error messages with Velero lowercase standards (#10558)
Signed-off-by: Abhayraj Jaiswal <abhayraj916146@gmail.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Align block and kopia snapshot error messages with Velero lowercase standards
|
||||
@@ -135,7 +135,7 @@ func snapshotSource(
|
||||
|
||||
snap, backupSize, err := u.Backup(source, parentBackup.parentObject, bitmap.Iterator(), uploaderCfg)
|
||||
if err != nil {
|
||||
return "", 0, 0, fallback, errors.Wrapf(err, "Failed to run uploader backup for si %v", source)
|
||||
return "", 0, 0, fallback, errors.Wrapf(err, "failed to run uploader backup for si %v", source)
|
||||
}
|
||||
|
||||
if snap.Tags == nil {
|
||||
@@ -152,11 +152,11 @@ func snapshotSource(
|
||||
|
||||
snapID, err := rep.SaveSnapshot(ctx, snap)
|
||||
if err != nil {
|
||||
return "", 0, 0, fallback, errors.Wrapf(err, "Failed to save snapshot %v", snap)
|
||||
return "", 0, 0, fallback, errors.Wrapf(err, "failed to save snapshot %v", snap)
|
||||
}
|
||||
|
||||
if err = rep.Flush(ctx); err != nil {
|
||||
return "", 0, 0, fallback, errors.Wrapf(err, "Failed to flush repository")
|
||||
return "", 0, 0, fallback, errors.Wrapf(err, "failed to flush repository")
|
||||
}
|
||||
|
||||
log.Infof("Created snapshot with root %v and ID %v in %v", snap.RootObject, snapID, time.Since(snapshotStartTime).Truncate(time.Second))
|
||||
@@ -209,7 +209,7 @@ func getParentBackupInfo(ctx context.Context, rep udmrepo.BackupRepo, forceFull
|
||||
}
|
||||
|
||||
if previous.Tags[uploader.CBTVolumeIDTag] != volumeID {
|
||||
return parentBackupInfo{}, errors.Errorf("VolumeID %s from parent snapshot %s is not expected as %s", previous.Tags[uploader.CBTVolumeIDTag], previous.ID, volumeID)
|
||||
return parentBackupInfo{}, errors.Errorf("volumeID %s from parent snapshot %s is not expected as %s", previous.Tags[uploader.CBTVolumeIDTag], previous.ID, volumeID)
|
||||
}
|
||||
|
||||
obj, err := loadObjectFromSnapshot(ctx, rep, previous)
|
||||
@@ -232,7 +232,7 @@ func Restore(ctx context.Context, blkUp Uploader, rep udmrepo.BackupRepo, snapsh
|
||||
|
||||
snapshot, err := rep.GetSnapshot(ctx, udmrepo.ID(snapshotID))
|
||||
if err != nil {
|
||||
return 0, 0, false, errors.Wrapf(err, "Unable to load snapshot %v", snapshotID)
|
||||
return 0, 0, false, errors.Wrapf(err, "unable to load snapshot %v", snapshotID)
|
||||
}
|
||||
log.Infof("Restore from snapshot %s, incremental %v, cbt source %v, description %s, created time %v, tags %v", snapshotID, incremental, cbtSource, snapshot.Description, snapshot.EndTime, snapshot.Tags)
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestBackup(t *testing.T) {
|
||||
blkup.On("Backup", mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(udmrepo.Snapshot{}, int64(0), errors.New("I/O error"))
|
||||
},
|
||||
expectedErrStr: "Failed to run uploader backup",
|
||||
expectedErrStr: "failed to run uploader backup",
|
||||
},
|
||||
{
|
||||
name: "success returns correct SnapshotInfo with snapshotSize larger than sourceSize",
|
||||
@@ -229,7 +229,7 @@ func TestSnapshotSource(t *testing.T) {
|
||||
blkup.On("Backup", mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(udmrepo.Snapshot{}, int64(0), errors.New("uploader error"))
|
||||
},
|
||||
expectedErrStr: "Failed to run uploader backup",
|
||||
expectedErrStr: "failed to run uploader backup",
|
||||
},
|
||||
{
|
||||
name: "SaveSnapshot error",
|
||||
@@ -239,7 +239,7 @@ func TestSnapshotSource(t *testing.T) {
|
||||
repo.On("SaveSnapshot", mock.Anything, mock.Anything).
|
||||
Return(udmrepo.ID(""), errors.New("save failed"))
|
||||
},
|
||||
expectedErrStr: "Failed to save snapshot",
|
||||
expectedErrStr: "failed to save snapshot",
|
||||
},
|
||||
{
|
||||
name: "Flush error",
|
||||
@@ -249,7 +249,7 @@ func TestSnapshotSource(t *testing.T) {
|
||||
repo.On("SaveSnapshot", mock.Anything, mock.Anything).Return(udmrepo.ID("snap-001"), nil)
|
||||
repo.On("Flush", mock.Anything).Return(errors.New("flush failed"))
|
||||
},
|
||||
expectedErrStr: "Failed to flush repository",
|
||||
expectedErrStr: "failed to flush repository",
|
||||
},
|
||||
{
|
||||
name: "success with nil cbtService falls back to full bitmap",
|
||||
@@ -550,7 +550,7 @@ func TestGetParentBackupInfo(t *testing.T) {
|
||||
},
|
||||
expectEmpty: true,
|
||||
expectErr: true,
|
||||
expectedErrStr: "VolumeID different-vol from parent snapshot snap-vidmismatch is not expected as vol-123",
|
||||
expectedErrStr: "volumeID different-vol from parent snapshot snap-vidmismatch is not expected as vol-123",
|
||||
},
|
||||
{
|
||||
name: "loadObjectFromSnapshot fails — falls back to full",
|
||||
@@ -883,7 +883,7 @@ func TestRestore(t *testing.T) {
|
||||
repo.On("GetSnapshot", mock.Anything, udmrepo.ID("snap-001")).
|
||||
Return(udmrepo.Snapshot{}, errors.New("not found"))
|
||||
},
|
||||
expectedErrStr: "Unable to load snapshot",
|
||||
expectedErrStr: "unable to load snapshot",
|
||||
},
|
||||
{
|
||||
name: "openBlockDevice error",
|
||||
|
||||
@@ -160,7 +160,7 @@ func Backup(ctx context.Context, fsUploader SnapshotUploader, repoWriter repo.Re
|
||||
}
|
||||
source, err := filepath.Abs(sourcePath)
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrapf(err, "Invalid source path '%s'", sourcePath)
|
||||
return nil, false, errors.Wrapf(err, "invalid source path '%s'", sourcePath)
|
||||
}
|
||||
|
||||
source = filepath.Clean(source)
|
||||
@@ -296,7 +296,7 @@ func SnapshotSource(
|
||||
|
||||
manifest, err := u.Upload(ctx, rootDir, policyTree, sourceInfo, previous...)
|
||||
if err != nil {
|
||||
return "", 0, fallback, errors.Wrapf(err, "Failed to upload the kopia snapshot for si %v", sourceInfo)
|
||||
return "", 0, fallback, errors.Wrapf(err, "failed to upload the kopia snapshot for si %v", sourceInfo)
|
||||
}
|
||||
|
||||
manifest.Tags = snapshotTags
|
||||
@@ -305,16 +305,16 @@ func SnapshotSource(
|
||||
manifest.Pins = []string{"velero-pin"}
|
||||
|
||||
if _, err = saveSnapshotFunc(ctx, rep, manifest); err != nil {
|
||||
return "", 0, fallback, errors.Wrapf(err, "Failed to save kopia manifest %v", manifest.ID)
|
||||
return "", 0, fallback, errors.Wrapf(err, "failed to save kopia manifest %v", manifest.ID)
|
||||
}
|
||||
|
||||
_, err = applyRetentionPolicyFunc(ctx, rep, sourceInfo, true)
|
||||
if err != nil {
|
||||
return "", 0, fallback, errors.Wrapf(err, "Failed to apply kopia retention policy for si %v", sourceInfo)
|
||||
return "", 0, fallback, errors.Wrapf(err, "failed to apply kopia retention policy for si %v", sourceInfo)
|
||||
}
|
||||
|
||||
if err = rep.Flush(ctx); err != nil {
|
||||
return "", 0, fallback, errors.Wrapf(err, "Failed to flush kopia repository")
|
||||
return "", 0, fallback, errors.Wrapf(err, "failed to flush kopia repository")
|
||||
}
|
||||
log.Infof("Created snapshot with root %v and ID %v in %v", manifest.RootObjectID(), manifest.ID, time.Since(snapshotStartTime).Truncate(time.Second))
|
||||
return reportSnapshotStatus(manifest, policyTree, fallback)
|
||||
@@ -414,19 +414,19 @@ func Restore(ctx context.Context, rep repo.RepositoryWriter, progress *Progress,
|
||||
|
||||
snapshot, err := snapshot.LoadSnapshot(kopiaCtx, rep, manifest.ID(snapshotID))
|
||||
if err != nil {
|
||||
return 0, 0, false, errors.Wrapf(err, "Unable to load snapshot %v", snapshotID)
|
||||
return 0, 0, false, errors.Wrapf(err, "unable to load snapshot %v", snapshotID)
|
||||
}
|
||||
|
||||
log.Infof("Restore from snapshot %s, description %s, created time %v, tags %v", snapshotID, snapshot.Description, snapshot.EndTime.ToTime(), snapshot.Tags)
|
||||
|
||||
rootEntry, err := filesystemEntryFunc(kopiaCtx, rep, snapshotID, false)
|
||||
if err != nil {
|
||||
return 0, 0, false, errors.Wrapf(err, "Unable to get filesystem entry for snapshot %v", snapshotID)
|
||||
return 0, 0, false, errors.Wrapf(err, "unable to get filesystem entry for snapshot %v", snapshotID)
|
||||
}
|
||||
|
||||
path, err := filepath.Abs(dest)
|
||||
if err != nil {
|
||||
return 0, 0, false, errors.Wrapf(err, "Unable to resolve path %v", dest)
|
||||
return 0, 0, false, errors.Wrapf(err, "unable to resolve path %v", dest)
|
||||
}
|
||||
|
||||
fsOutput := &restore.FilesystemOutput{
|
||||
@@ -506,14 +506,14 @@ func Restore(ctx context.Context, rep repo.RepositoryWriter, progress *Progress,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return 0, 0, false, errors.Wrapf(err, "Failed to copy snapshot data to the target")
|
||||
return 0, 0, false, errors.Wrapf(err, "failed to copy snapshot data to the target")
|
||||
}
|
||||
|
||||
if err := output.Flush(); err != nil {
|
||||
if err == errFlushUnsupported {
|
||||
log.Warnf("Skip flushing data for %v under the current OS %v", path, runtime.GOOS)
|
||||
} else {
|
||||
return 0, 0, false, errors.Wrapf(err, "Failed to flush data to target")
|
||||
return 0, 0, false, errors.Wrapf(err, "failed to flush data to target")
|
||||
}
|
||||
} else {
|
||||
log.Infof("Flush done for volume dir %v", path)
|
||||
|
||||
@@ -697,12 +697,12 @@ func TestRestore(t *testing.T) {
|
||||
name: "manifest is not a snapshot",
|
||||
invalidManifestType: true,
|
||||
dest: "/path/to/destination",
|
||||
expectedError: errors.New("Unable to load snapshot"),
|
||||
expectedError: errors.New("unable to load snapshot"),
|
||||
},
|
||||
{
|
||||
name: "Failed to get filesystem entry",
|
||||
snapshotID: "snapshot-123",
|
||||
expectedError: errors.New("Unable to get filesystem entry"),
|
||||
expectedError: errors.New("unable to get filesystem entry"),
|
||||
},
|
||||
{
|
||||
name: "Failed to restore with filesystem entry",
|
||||
@@ -710,10 +710,10 @@ func TestRestore(t *testing.T) {
|
||||
return snapshotfs.EntryFromDirEntry(rep, &snapshot.DirEntry{Type: snapshot.EntryTypeFile}), nil
|
||||
},
|
||||
restoreEntryFunc: func(ctx context.Context, rep repo.Repository, output restore.Output, rootEntry fs.Entry, options restore.Options) (restore.Stats, error) {
|
||||
return restore.Stats{}, errors.New("Unable to get filesystem entry")
|
||||
return restore.Stats{}, errors.New("unable to get filesystem entry")
|
||||
},
|
||||
snapshotID: "snapshot-123",
|
||||
expectedError: errors.New("Unable to get filesystem entry"),
|
||||
expectedError: errors.New("unable to get filesystem entry"),
|
||||
},
|
||||
{
|
||||
name: "Expect successful",
|
||||
|
||||
Reference in New Issue
Block a user