mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-05 13:05:17 +00:00
snapshot size in restore CRs only
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -123,10 +123,6 @@ type PodVolumeBackupStatus struct {
|
||||
// +optional
|
||||
// +nullable
|
||||
AcceptedTimestamp *metav1.Time `json:"acceptedTimestamp,omitempty"`
|
||||
|
||||
// SnapshotSize is the logical size of the snapshot.
|
||||
// +optional
|
||||
SnapshotSize int64 `json:"snapshotSize,omitempty"`
|
||||
}
|
||||
|
||||
// TODO(2.0) After converting all resources to use the runttime-controller client,
|
||||
|
||||
@@ -172,10 +172,6 @@ type DataUploadStatus struct {
|
||||
// +optional
|
||||
// +nullable
|
||||
AcceptedTimestamp *metav1.Time `json:"acceptedTimestamp,omitempty"`
|
||||
|
||||
// SnapshotSize is the logical size of the snapshot.
|
||||
// +optional
|
||||
SnapshotSize int64 `json:"snapshotSize,omitempty"`
|
||||
}
|
||||
|
||||
// TODO(2.0) After converting all resources to use the runttime-controller client,
|
||||
|
||||
@@ -181,14 +181,8 @@ func (d *DataUploadBuilder) Message(msg string) *DataUploadBuilder {
|
||||
return d
|
||||
}
|
||||
|
||||
// SnapshotSize sets the DataUpload's SnapshotSize.
|
||||
func (d *DataUploadBuilder) SnapshotSize(size int64) *DataUploadBuilder {
|
||||
d.object.Status.SnapshotSize = size
|
||||
return d
|
||||
}
|
||||
|
||||
// TotalBytes sets the DataUpload's TotalBytes.
|
||||
func (d *DataUploadBuilder) TotalBytes(size int64) *DataUploadBuilder {
|
||||
d.object.Status.SnapshotSize = size
|
||||
d.object.Status.Progress.TotalBytes = size
|
||||
return d
|
||||
}
|
||||
|
||||
@@ -493,7 +493,6 @@ func (r *DataUploadReconciler) OnDataUploadCompleted(ctx context.Context, namesp
|
||||
du.Status.Path = result.Backup.Source.ByPath
|
||||
du.Status.Phase = velerov2alpha1api.DataUploadPhaseCompleted
|
||||
du.Status.SnapshotID = result.Backup.SnapshotID
|
||||
du.Status.SnapshotSize = result.Backup.TotalBytes
|
||||
du.Status.CompletionTimestamp = &metav1.Time{Time: r.Clock.Now()}
|
||||
if result.Backup.EmptySnapshot {
|
||||
du.Status.Message = "volume was empty so no data was upload"
|
||||
|
||||
@@ -856,7 +856,6 @@ func TestOnDataUploadCompleted(t *testing.T) {
|
||||
Source: datapath.AccessPoint{
|
||||
ByPath: "fake-path",
|
||||
},
|
||||
TotalBytes: int64(1000),
|
||||
},
|
||||
})
|
||||
updatedDu := &velerov2alpha1api.DataUpload{}
|
||||
@@ -865,7 +864,6 @@ func TestOnDataUploadCompleted(t *testing.T) {
|
||||
assert.False(t, updatedDu.Status.CompletionTimestamp.IsZero())
|
||||
assert.Equal(t, "fake-id", updatedDu.Status.SnapshotID)
|
||||
assert.Equal(t, "fake-path", updatedDu.Status.Path)
|
||||
assert.Equal(t, int64(1000), updatedDu.Status.SnapshotSize)
|
||||
}
|
||||
|
||||
func TestFindDataUploadForPod(t *testing.T) {
|
||||
|
||||
@@ -525,7 +525,6 @@ func (r *PodVolumeBackupReconciler) OnDataPathCompleted(ctx context.Context, nam
|
||||
pvb.Status.Path = result.Backup.Source.ByPath
|
||||
pvb.Status.Phase = velerov1api.PodVolumeBackupPhaseCompleted
|
||||
pvb.Status.SnapshotID = result.Backup.SnapshotID
|
||||
pvb.Status.SnapshotSize = result.Backup.TotalBytes
|
||||
pvb.Status.CompletionTimestamp = &completionTime
|
||||
if result.Backup.EmptySnapshot {
|
||||
pvb.Status.Message = "volume was empty so no snapshot was taken"
|
||||
|
||||
@@ -93,14 +93,9 @@ func getVolumeBackupInfoForPod(podVolumeBackups []*velerov1api.PodVolumeBackup,
|
||||
continue
|
||||
}
|
||||
|
||||
snapshotSize := pvb.Status.SnapshotSize
|
||||
if snapshotSize == 0 {
|
||||
snapshotSize = pvb.Status.Progress.TotalBytes
|
||||
}
|
||||
|
||||
volumes[pvb.Spec.Volume] = volumeBackupInfo{
|
||||
snapshotID: pvb.Status.SnapshotID,
|
||||
snapshotSize: snapshotSize,
|
||||
snapshotSize: pvb.Status.Progress.TotalBytes,
|
||||
uploaderType: getUploaderTypeOrDefault(pvb.Spec.UploaderType),
|
||||
repositoryType: getRepositoryType(pvb.Spec.UploaderType),
|
||||
}
|
||||
|
||||
@@ -72,16 +72,11 @@ func (d *DataUploadRetrieveAction) Execute(input *velero.RestoreItemActionExecut
|
||||
return nil, errors.Wrapf(err, "error to get backup for restore %s", input.Restore.Name)
|
||||
}
|
||||
|
||||
snapshotSize := dataUpload.Status.SnapshotSize
|
||||
if snapshotSize == 0 {
|
||||
snapshotSize = dataUpload.Status.Progress.TotalBytes
|
||||
}
|
||||
|
||||
dataUploadResult := velerov2alpha1.DataUploadResult{
|
||||
BackupStorageLocation: backup.Spec.StorageLocation,
|
||||
DataMover: dataUpload.Spec.DataMover,
|
||||
SnapshotID: dataUpload.Status.SnapshotID,
|
||||
SnapshotSize: snapshotSize,
|
||||
SnapshotSize: dataUpload.Status.Progress.TotalBytes,
|
||||
SourceNamespace: dataUpload.Spec.SourceNamespace,
|
||||
DataMoverResult: dataUpload.Status.DataMoverResult,
|
||||
NodeOS: dataUpload.Status.NodeOS,
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestDataUploadRetrieveActionExectue(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "DataUploadRetrieve Action test",
|
||||
dataUpload: builder.ForDataUpload("velero", "testDU").SourceNamespace("testNamespace").SourcePVC("testPVC").SnapshotID("fake-id").SnapshotSize(1000).Result(),
|
||||
dataUpload: builder.ForDataUpload("velero", "testDU").SourceNamespace("testNamespace").SourcePVC("testPVC").SnapshotID("fake-id").TotalBytes(1000).Result(),
|
||||
restore: builder.ForRestore("velero", "testRestore").ObjectMeta(builder.WithUID("testingUID")).Backup("testBackup").Result(),
|
||||
runtimeScheme: scheme,
|
||||
veleroObjs: []runtime.Object{
|
||||
@@ -76,16 +76,6 @@ func TestDataUploadRetrieveActionExectue(t *testing.T) {
|
||||
},
|
||||
expectedDataUploadResult: builder.ForConfigMap("velero", "").ObjectMeta(builder.WithGenerateName("testDU-"), builder.WithLabels(velerov1.PVCNamespaceNameLabel, "migre209d0da-49c7-45ba-8d5a-3e59fd591ec1.kibishii-data-ki152333", velerov1.RestoreUIDLabel, "testingUID", velerov1.ResourceUsageLabel, string(velerov1.VeleroResourceUsageDataUploadResult))).Data("testingUID", `{"backupStorageLocation":"testLocation","sourceNamespace":"migre209d0da-49c7-45ba-8d5a-3e59fd591ec1"}`).Result(),
|
||||
},
|
||||
{
|
||||
name: "snapshotSize is zero",
|
||||
dataUpload: builder.ForDataUpload("velero", "testDU").SourceNamespace("testNamespace").SourcePVC("testPVC").TotalBytes(2000).Result(),
|
||||
restore: builder.ForRestore("velero", "testRestore").ObjectMeta(builder.WithUID("testingUID")).Backup("testBackup").Result(),
|
||||
runtimeScheme: scheme,
|
||||
veleroObjs: []runtime.Object{
|
||||
builder.ForBackup("velero", "testBackup").StorageLocation("testLocation").Result(),
|
||||
},
|
||||
expectedDataUploadResult: builder.ForConfigMap("velero", "").ObjectMeta(builder.WithGenerateName("testDU-"), builder.WithLabels(velerov1.PVCNamespaceNameLabel, "testNamespace.testPVC", velerov1.RestoreUIDLabel, "testingUID", velerov1.ResourceUsageLabel, string(velerov1.VeleroResourceUsageDataUploadResult))).Data("testingUID", `{"backupStorageLocation":"testLocation","sourceNamespace":"testNamespace","snapshotSize":2000}`).Result(),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
||||
Reference in New Issue
Block a user