relocate the backup/restore types in volumeInfo

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2026-09-10 15:50:39 +08:00
parent 159e98e906
commit b273b78795
3 changed files with 24 additions and 31 deletions
+16 -24
View File
@@ -93,6 +93,9 @@ type BackupVolumeInfo struct {
// How volume data is backed up, with possible values including Full and Incremental.
BackupType velerov1api.BackupType `json:"backupType,omitempty"`
// FallbackFull indicates whether the incremental backup fallbacks to full backup
FallbackFull bool `json:"fallbackFull,omitempty"`
CSISnapshotInfo *CSISnapshotInfo `json:"csiSnapshotInfo,omitempty"`
SnapshotDataMovementInfo *BackupSnapshotDataMovementInfo `json:"snapshotDataMovementInfo,omitempty"`
NativeSnapshotInfo *NativeSnapshotInfo `json:"nativeSnapshotInfo,omitempty"`
@@ -126,6 +129,12 @@ type RestoreVolumeInfo struct {
// Whether the volume's data are restored via data movement
SnapshotDataMoved bool `json:"snapshotDataMoved"`
// Indicates the type of the restore, incremental or full.
RestoreType string `json:"restoreType,omitempty"`
// FallbackFull indicates whether the incremental restore fallbacks to full restore
FallbackFull bool `json:"fallbackFull,omitempty"`
CSISnapshotInfo *CSISnapshotInfo `json:"csiSnapshotInfo,omitempty"`
SnapshotDataMovementInfo *RestoreSnapshotDataMovementInfo `json:"snapshotDataMovementInfo,omitempty"`
NativeSnapshotInfo *NativeSnapshotInfo `json:"nativeSnapshotInfo,omitempty"`
@@ -185,18 +194,9 @@ type BackupSnapshotDataMovementInfo struct {
// incremental and must stay distinguishable from "unknown".
IncrementalSize *int64 `json:"incrementalSize,omitempty"`
// ParentSnapshot specifies the parent snapshot that current backup is based on.
// If its value is "" or "auto", the data mover finds the recent backup of the same volume as parent.
// If its value is "none", the data mover will do a full backup
// If its value is a specific snapshotID, the data mover finds the specific snapshot as parent.
ParentSnapshot string `json:"parentSnapshot,omitempty"`
// The size of source volume, for backup only
SourceSize int64 `json:"sourceSize,omitempty"`
// FallbackFull indicates whether the incremental backup fallbacks to full backup
FallbackFull bool `json:"fallbackFull,omitempty"`
// The DataUpload's Status.Phase value
Phase velerov2alpha1.DataUploadPhase `json:"phase"`
}
@@ -231,12 +231,6 @@ type RestoreSnapshotDataMovementInfo struct {
// The DataDownload's Status.Phase value
Phase velerov2alpha1.DataDownloadPhase `json:"phase"`
// Indicates the type of the restore, incremental or full.
RestoreType string `json:"restoreType,omitempty"`
// FallbackFull indicates whether the incremental restore fallbacks to full restore
FallbackFull bool `json:"fallbackFull,omitempty"`
}
// NativeSnapshotInfo is used for displaying the Velero native snapshot status.
@@ -309,6 +303,9 @@ type PodVolumeBackupInfo struct {
// FallbackFull indicates whether the incremental backup fallbacks to full backup
FallbackFull bool `json:"fallbackFull,omitempty"`
// BackupType indicates the type of the backup, incremental or full.
BackupType string `json:"backupType,omitempty"`
// The PVB's Status.Phase value
Phase velerov1api.PodVolumeBackupPhase `json:"phase,omitempty"`
}
@@ -344,12 +341,6 @@ type PodVolumeRestoreInfo struct {
// The PVR's Status.Phase value
Phase velerov1api.PodVolumeRestorePhase `json:"phase,omitempty"`
// Indicates the type of the restore, incremental or full.
RestoreType string `json:"restoreType,omitempty"`
// FallbackFull indicates whether the incremental restore fallbacks to full restore
FallbackFull bool `json:"fallbackFull,omitempty"`
}
func newPodVolumeInfoFromPVB(pvb *velerov1api.PodVolumeBackup) *PodVolumeBackupInfo {
@@ -377,7 +368,6 @@ func newPodVolumeInfoFromPVR(pvr *velerov1api.PodVolumeRestore) *PodVolumeRestor
PodName: pvr.Spec.Pod.Name,
PodNamespace: pvr.Spec.Pod.Namespace,
Phase: pvr.Status.Phase,
RestoreType: pvr.Spec.RestoreType,
}
}
@@ -629,6 +619,7 @@ func (v *BackupVolumesInformation) generateVolumeInfoFromPVB() {
CompletionTimestamp: pvb.Status.CompletionTimestamp,
PVBInfo: newPodVolumeInfoFromPVB(pvb),
BackupType: velerov1api.BackupTypeIncremental,
FallbackFull: pvb.Status.FallbackFull,
}
if pvb.Spec.ParentSnapshot == veleroshared.ParentSnapshotNone {
@@ -761,7 +752,6 @@ func (v *BackupVolumesInformation) generateVolumeInfoFromDataUpload() {
UploaderType: datamover.GetUploaderType(dataMover),
OperationID: operation.Spec.OperationID,
Phase: dataUpload.Status.Phase,
ParentSnapshot: dataUpload.Spec.ParentSnapshot,
Size: dataUpload.Status.Progress.TotalBytes,
SnapshotHandle: dataUpload.Status.SnapshotID,
},
@@ -917,6 +907,8 @@ func (t *RestoreVolumeInfoTracker) Result() []*RestoreVolumeInfo {
SnapshotDataMoved: false,
PVRInfo: newPodVolumeInfoFromPVR(pvr),
RestoreMethod: PodVolumeRestore,
RestoreType: pvr.Spec.RestoreType,
FallbackFull: pvr.Status.FallbackFull,
}
pvcName, err := pvcByPodvolume(context.TODO(), t.client, pvr.Spec.Pod.Name, pvr.Spec.Pod.Namespace, pvr.Spec.Volume)
if err != nil {
@@ -1014,12 +1006,12 @@ func (t *RestoreVolumeInfoTracker) Result() []*RestoreVolumeInfo {
// the datadownload was initiated in CSI plugin
// For the same reason, no CSI snapshot info will be populated into volumeInfo
RestoreMethod: CSISnapshot,
RestoreType: dd.Spec.RestoreType,
SnapshotDataMovementInfo: &RestoreSnapshotDataMovementInfo{
DataMover: dataMover,
UploaderType: datamover.GetUploaderType(dataMover),
SnapshotHandle: dd.Spec.SnapshotID,
OperationID: operationID,
RestoreType: dd.Spec.RestoreType,
Size: dd.Status.Progress.TotalBytes,
Phase: dd.Status.Phase,
},
+7 -6
View File
@@ -1237,6 +1237,7 @@ func TestRestoreVolumeInfoResult(t *testing.T) {
PVName: "testPV",
RestoreMethod: CSISnapshot,
SnapshotDataMoved: true,
RestoreType: "Incremental",
SnapshotDataMovementInfo: &RestoreSnapshotDataMovementInfo{
DataMover: "velero",
UploaderType: velerov1api.BackupRepositoryTypeKopia,
@@ -1244,7 +1245,6 @@ func TestRestoreVolumeInfoResult(t *testing.T) {
OperationID: "dd-operation-001",
Phase: velerov2alpha1.DataDownloadPhaseCompleted,
Size: 2048,
RestoreType: "Incremental",
},
},
{
@@ -1253,6 +1253,7 @@ func TestRestoreVolumeInfoResult(t *testing.T) {
PVName: "testPV2",
RestoreMethod: CSISnapshot,
SnapshotDataMoved: true,
RestoreType: "Full",
SnapshotDataMovementInfo: &RestoreSnapshotDataMovementInfo{
DataMover: "velero",
UploaderType: velerov1api.BackupRepositoryTypeKopia,
@@ -1260,7 +1261,6 @@ func TestRestoreVolumeInfoResult(t *testing.T) {
OperationID: "dd-operation-002",
Phase: velerov2alpha1.DataDownloadPhaseCompleted,
Size: 4096,
RestoreType: "Full",
},
},
},
@@ -1315,6 +1315,7 @@ func TestBackupVolumeInfoJSONRoundTrip(t *testing.T) {
Skipped: false,
Result: VolumeResultSucceeded,
BackupType: velerov1api.BackupTypeIncremental,
FallbackFull: true,
CSISnapshotInfo: &CSISnapshotInfo{
SnapshotHandle: "csi-snap-1",
Size: 2000,
@@ -1331,7 +1332,6 @@ func TestBackupVolumeInfoJSONRoundTrip(t *testing.T) {
OperationID: "op-1",
Size: 1000,
IncrementalSize: int64Ptr(200),
ParentSnapshot: "parent-1",
Phase: velerov2alpha1.DataUploadPhaseCompleted,
},
NativeSnapshotInfo: &NativeSnapshotInfo{
@@ -1376,7 +1376,7 @@ func TestBackupVolumeInfoJSONRoundTrip(t *testing.T) {
assert.Contains(t, jsonStr, `"operationID":"op-1"`)
assert.Contains(t, jsonStr, `"size":1000`)
assert.Contains(t, jsonStr, `"incrementalSize":200`)
assert.Contains(t, jsonStr, `"parentSnapshot":"parent-1"`)
assert.Contains(t, jsonStr, `"fallbackFull":true`)
assert.Contains(t, jsonStr, `"phase":"Completed"`)
assert.Contains(t, jsonStr, `"pvbInfo":{`)
assert.Contains(t, jsonStr, `"podName":"pod-1"`)
@@ -1406,6 +1406,8 @@ func TestRestoreVolumeInfoJSONRoundTrip(t *testing.T) {
PVName: "pv-2",
RestoreMethod: CSISnapshot,
SnapshotDataMoved: true,
RestoreType: "Incremental",
FallbackFull: true,
SnapshotDataMovementInfo: &RestoreSnapshotDataMovementInfo{
DataMover: "velero",
UploaderType: "kopia",
@@ -1415,7 +1417,6 @@ func TestRestoreVolumeInfoJSONRoundTrip(t *testing.T) {
Size: 3000,
IncrementalSize: int64Ptr(300),
Phase: velerov2alpha1.DataDownloadPhaseCompleted,
RestoreType: "Incremental",
},
PVRInfo: &PodVolumeRestoreInfo{
SnapshotHandle: "pvr-snap-1",
@@ -1427,7 +1428,6 @@ func TestRestoreVolumeInfoJSONRoundTrip(t *testing.T) {
PodNamespace: "ns-2",
NodeName: "node-2",
Phase: velerov1api.PodVolumeRestorePhaseCompleted,
RestoreType: "Incremental",
},
CSISnapshotInfo: &CSISnapshotInfo{
SnapshotHandle: "csi-snap-2",
@@ -1462,6 +1462,7 @@ func TestRestoreVolumeInfoJSONRoundTrip(t *testing.T) {
assert.Contains(t, jsonStr, `"incrementalSize":300`)
assert.Contains(t, jsonStr, `"phase":"Completed"`)
assert.Contains(t, jsonStr, `"restoreType":"Incremental"`)
assert.Contains(t, jsonStr, `"fallbackFull":true`)
assert.Contains(t, jsonStr, `"pvrInfo":{`)
assert.Contains(t, jsonStr, `"podName":"pod-2"`)
assert.Contains(t, jsonStr, `"podNamespace":"ns-2"`)
+1 -1
View File
@@ -1330,7 +1330,7 @@ func updateVolumeInfos(
volumeInfos[index].SnapshotDataMovementInfo.IncrementalSize = dataUpload.Status.IncrementalBytes
volumeInfos[index].SnapshotDataMovementInfo.SourceSize = dataUpload.Status.SourceSize
volumeInfos[index].SnapshotDataMovementInfo.Phase = dataUpload.Status.Phase
volumeInfos[index].SnapshotDataMovementInfo.FallbackFull = dataUpload.Status.FallbackFull
volumeInfos[index].FallbackFull = dataUpload.Status.FallbackFull
if dataUpload.Status.Phase == velerov2alpha1.DataUploadPhaseCompleted {
volumeInfos[index].Result = volume.VolumeResultSucceeded