mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-13 11:34:54 +00:00
Merge pull request #10506 from Lyndon-Li/save-source-size-to-backup
Save source size to volume info
This commit is contained in:
@@ -197,7 +197,7 @@ func (dp *generalDataPath) StartBackup(source AccessPoint, uploaderConfig map[st
|
||||
dp.wgDataPath.Done()
|
||||
}()
|
||||
|
||||
snapshotID, emptySnapshot, totalBytes, incrementalBytes, err := dp.uploaderProv.RunBackup(
|
||||
snapshotID, emptySnapshot, totalBytes, incrementalBytes, sourceSize, err := dp.uploaderProv.RunBackup(
|
||||
dp.ctx,
|
||||
source.ByPath,
|
||||
backupParam.RealSource,
|
||||
@@ -226,7 +226,14 @@ func (dp *generalDataPath) StartBackup(source AccessPoint, uploaderConfig map[st
|
||||
}
|
||||
dp.callbacks.OnFailed(context.Background(), dp.namespace, dp.jobName, dataPathErr)
|
||||
} else {
|
||||
dp.callbacks.OnCompleted(context.Background(), dp.namespace, dp.jobName, Result{Backup: BackupResult{snapshotID, emptySnapshot, source, totalBytes, ptr.To(incrementalBytes)}})
|
||||
dp.callbacks.OnCompleted(context.Background(), dp.namespace, dp.jobName, Result{Backup: BackupResult{
|
||||
SnapshotID: snapshotID,
|
||||
EmptySnapshot: emptySnapshot,
|
||||
Source: source,
|
||||
TotalBytes: totalBytes,
|
||||
IncrementalBytes: ptr.To(incrementalBytes),
|
||||
SourceSize: sourceSize,
|
||||
}})
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestAsyncBackup(t *testing.T) {
|
||||
err: provider.ErrorCanceled,
|
||||
},
|
||||
{
|
||||
name: "async backup complete",
|
||||
name: "async backup complete with totalBytes larger than sourceSize",
|
||||
callbacks: Callbacks{
|
||||
OnFailed: nil,
|
||||
OnCancelled: nil,
|
||||
@@ -86,8 +86,32 @@ func TestAsyncBackup(t *testing.T) {
|
||||
SnapshotID: "fake-snapshot",
|
||||
EmptySnapshot: false,
|
||||
Source: AccessPoint{ByPath: "fake-path"},
|
||||
TotalBytes: 1000,
|
||||
IncrementalBytes: ptr.To(int64(0)),
|
||||
TotalBytes: 3000,
|
||||
IncrementalBytes: ptr.To(int64(200)),
|
||||
SourceSize: 2000,
|
||||
},
|
||||
},
|
||||
path: "fake-path",
|
||||
},
|
||||
{
|
||||
name: "async backup complete with totalBytes equal to sourceSize",
|
||||
callbacks: Callbacks{
|
||||
OnFailed: nil,
|
||||
OnCancelled: nil,
|
||||
OnCompleted: func(ctx context.Context, namespace string, job string, result Result) {
|
||||
asyncResult = result
|
||||
asyncErr = nil
|
||||
finish <- struct{}{}
|
||||
},
|
||||
},
|
||||
result: Result{
|
||||
Backup: BackupResult{
|
||||
SnapshotID: "fake-snapshot",
|
||||
EmptySnapshot: false,
|
||||
Source: AccessPoint{ByPath: "fake-path"},
|
||||
TotalBytes: 2000,
|
||||
IncrementalBytes: ptr.To(int64(200)),
|
||||
SourceSize: 2000,
|
||||
},
|
||||
},
|
||||
path: "fake-path",
|
||||
@@ -102,7 +126,7 @@ func TestAsyncBackup(t *testing.T) {
|
||||
if test.result.Backup.IncrementalBytes != nil {
|
||||
incrementalBytes = *test.result.Backup.IncrementalBytes
|
||||
}
|
||||
mockProvider.On("RunBackup", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(test.result.Backup.SnapshotID, test.result.Backup.EmptySnapshot, test.result.Backup.TotalBytes, incrementalBytes, test.err)
|
||||
mockProvider.On("RunBackup", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(test.result.Backup.SnapshotID, test.result.Backup.EmptySnapshot, test.result.Backup.TotalBytes, incrementalBytes, test.result.Backup.SourceSize, test.err)
|
||||
mockProvider.On("Close", mock.Anything).Return(nil)
|
||||
dp.uploaderProv = mockProvider
|
||||
dp.initialized = true
|
||||
|
||||
@@ -39,6 +39,7 @@ type BackupResult struct {
|
||||
// while a current mover reporting a genuine zero still serializes the key and
|
||||
// unmarshals to a non-nil zero, distinguishing "measured zero" from "not measured".
|
||||
IncrementalBytes *int64 `json:"incrementalBytes,omitempty"`
|
||||
SourceSize int64 `json:"sourceSize,omitempty"`
|
||||
}
|
||||
|
||||
// RestoreResult represents the result of a restore
|
||||
|
||||
Reference in New Issue
Block a user