add backup/restore type and fallback to backup/restore describe

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2026-09-10 17:23:46 +08:00
parent f584d76b32
commit f9ebe14e16
8 changed files with 179 additions and 16 deletions
+10 -3
View File
@@ -741,6 +741,16 @@ func describeDataMovement(d *Describer, details bool, info *volume.BackupVolumeI
dataMover = info.SnapshotDataMovementInfo.DataMover
}
d.Printf("\t\t\t\tData Mover: %s\n", dataMover)
if info.BackupType != "" {
backupType := string(info.BackupType)
if info.FallbackFull {
backupType += " (fallen back to Full)"
}
d.Printf("\t\t\t\tBackup Type: %s\n", backupType)
}
d.Printf("\t\t\t\tUploader Type: %s\n", info.SnapshotDataMovementInfo.UploaderType)
d.Printf("\t\t\t\tMoved data Size (bytes): %d\n", info.SnapshotDataMovementInfo.Size)
// Print whenever the uploader measured a figure, including zero. A zero-delta
@@ -750,9 +760,6 @@ func describeDataMovement(d *Describer, details bool, info *volume.BackupVolumeI
if info.SnapshotDataMovementInfo.IncrementalSize != nil {
d.Printf("\t\t\t\tIncremental data Size (bytes): %d\n", *info.SnapshotDataMovementInfo.IncrementalSize)
}
if info.SnapshotDataMovementInfo.ParentSnapshot != "" {
d.Printf("\t\t\t\tParent Snapshot: %s\n", info.SnapshotDataMovementInfo.ParentSnapshot)
}
d.Printf("\t\t\t\tResult: %s\n", info.Result)
} else {
+36 -2
View File
@@ -635,7 +635,6 @@ func TestCSISnapshots(t *testing.T) {
Size: 100,
IncrementalSize: ptr.To(int64(50)),
Phase: velerov2alpha1.DataUploadPhaseFailed,
ParentSnapshot: "fake-parent-snapshot",
},
},
},
@@ -645,11 +644,46 @@ func TestCSISnapshots(t *testing.T) {
Data Movement:
Operation ID: fake-operation-5
Data Mover: velero
Backup Type: Incremental
Uploader Type: fake-uploader
Moved data Size (bytes): 100
Incremental data Size (bytes): 50
Parent Snapshot: fake-parent-snapshot
Result: failed
`,
},
{
name: "details, data movement, incremental fallback to full",
volumeInfo: []*volume.BackupVolumeInfo{
{
BackupMethod: volume.CSISnapshot,
PVCNamespace: "pvc-ns-6",
PVCName: "pvc-6",
Result: volume.VolumeResultSucceeded,
SnapshotDataMoved: true,
BackupType: velerov1api.BackupTypeIncremental,
FallbackFull: true,
SnapshotDataMovementInfo: &volume.BackupSnapshotDataMovementInfo{
DataMover: "velero",
UploaderType: "fake-uploader",
SnapshotHandle: "fake-repo-id-6",
OperationID: "fake-operation-6",
Size: 200,
IncrementalSize: ptr.To(int64(200)),
Phase: velerov2alpha1.DataUploadPhaseCompleted,
},
},
},
inputDetails: true,
expect: ` CSI Snapshots:
pvc-ns-6/pvc-6:
Data Movement:
Operation ID: fake-operation-6
Data Mover: velero
Backup Type: Incremental (fallen back to Full)
Uploader Type: fake-uploader
Moved data Size (bytes): 200
Incremental data Size (bytes): 200
Result: succeeded
`,
},
}
@@ -462,6 +462,15 @@ func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snaps
dataMovement := make(map[string]any)
dataMovement["operationID"] = info.SnapshotDataMovementInfo.OperationID
if info.BackupType != "" {
backupType := string(info.BackupType)
if info.FallbackFull {
backupType += " (fallen back to Full)"
}
dataMovement["backupType"] = backupType
}
dataMover := "velero"
if info.SnapshotDataMovementInfo.DataMover != "" {
dataMover = info.SnapshotDataMovementInfo.DataMover
@@ -478,9 +487,6 @@ func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snaps
if info.SnapshotDataMovementInfo.IncrementalSize != nil {
dataMovement["incrementalSize"] = *info.SnapshotDataMovementInfo.IncrementalSize
}
if info.SnapshotDataMovementInfo.ParentSnapshot != "" {
dataMovement["parentSnapshot"] = info.SnapshotDataMovementInfo.ParentSnapshot
}
snapshotDetail["dataMovement"] = dataMovement
} else {
@@ -585,7 +585,6 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
Size: 100,
IncrementalSize: ptr.To(int64(50)),
Phase: velerov2alpha1.DataUploadPhaseFailed,
ParentSnapshot: "fake-parent-snapshot",
},
},
},
@@ -596,11 +595,50 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
"dataMovement": map[string]any{
"operationID": "fake-operation-4",
"dataMover": "velero",
"backupType": "Incremental",
"uploaderType": "fake-uploader",
"size": int64(100),
"incrementalSize": int64(50),
"result": "failed",
"parentSnapshot": "fake-parent-snapshot",
},
},
},
},
},
{
name: "details, data movement, incremental fallback to full",
volumeInfo: []*volume.BackupVolumeInfo{
{
BackupMethod: volume.CSISnapshot,
PVCNamespace: "pvc-ns-5",
Result: volume.VolumeResultSucceeded,
PVCName: "pvc-5",
SnapshotDataMoved: true,
BackupType: velerov1api.BackupTypeIncremental,
FallbackFull: true,
SnapshotDataMovementInfo: &volume.BackupSnapshotDataMovementInfo{
DataMover: "velero",
UploaderType: "fake-uploader",
SnapshotHandle: "fake-repo-id-5",
OperationID: "fake-operation-5",
Size: 200,
IncrementalSize: ptr.To(int64(200)),
Phase: velerov2alpha1.DataUploadPhaseCompleted,
},
},
},
inputDetails: true,
expect: map[string]any{
"csiSnapshots": map[string]any{
"pvc-ns-5/pvc-5": map[string]any{
"dataMovement": map[string]any{
"operationID": "fake-operation-5",
"dataMover": "velero",
"backupType": "Incremental (fallen back to Full)",
"uploaderType": "fake-uploader",
"size": int64(200),
"incrementalSize": int64(200),
"result": "succeeded",
},
},
},
+7 -2
View File
@@ -473,8 +473,13 @@ func describeCSISnapshotsRestores(d *Describer, restoreVolInfo []volume.RestoreV
d.Printf("\t\t\tOperation ID: %s\n", info.SnapshotDataMovementInfo.OperationID)
d.Printf("\t\t\tData Mover: %s\n", info.SnapshotDataMovementInfo.DataMover)
d.Printf("\t\t\tUploader Type: %s\n", info.SnapshotDataMovementInfo.UploaderType)
if info.SnapshotDataMovementInfo.RestoreType != "" {
d.Printf("\t\t\tRestore Type: %s\n", info.SnapshotDataMovementInfo.RestoreType)
if info.RestoreType != "" {
restoreType := info.RestoreType
if info.FallbackFull {
restoreType += " (fallen back to Full)"
}
d.Printf("\t\t\tRestore Type: %s\n", restoreType)
}
if info.SnapshotDataMovementInfo.Size > 0 {
d.Printf("\t\t\tRestored data Size (bytes): %d\n", info.SnapshotDataMovementInfo.Size)
+34 -1
View File
@@ -312,13 +312,13 @@ CSI Snapshot Restores:
PVName: "pv-3",
RestoreMethod: volume.CSISnapshot,
SnapshotDataMoved: true,
RestoreType: "Incremental",
SnapshotDataMovementInfo: &volume.RestoreSnapshotDataMovementInfo{
OperationID: "op-3",
DataMover: "velero",
UploaderType: "kopia",
Size: 1234,
IncrementalSize: ptr.To(int64(500)),
RestoreType: "Incremental",
},
},
},
@@ -333,6 +333,39 @@ CSI Snapshot Restores:
Restore Type: Incremental
Restored data Size (bytes): 1234
Incremental data Size (bytes): 500
`,
},
{
name: "CSI restore with data movement, detailed, fallback to full",
inputVolInfoList: []volume.RestoreVolumeInfo{
{
PVCName: "pvc-4",
PVCNamespace: "ns-4",
PVName: "pv-4",
RestoreMethod: volume.CSISnapshot,
SnapshotDataMoved: true,
RestoreType: "Incremental",
FallbackFull: true,
SnapshotDataMovementInfo: &volume.RestoreSnapshotDataMovementInfo{
OperationID: "op-4",
DataMover: "velero",
UploaderType: "kopia",
Size: 2345,
IncrementalSize: ptr.To(int64(600)),
},
},
},
inputDetail: true,
expect: `
CSI Snapshot Restores:
ns-4/pvc-4:
Data Movement:
Operation ID: op-4
Data Mover: velero
Uploader Type: kopia
Restore Type: Incremental (fallen back to Full)
Restored data Size (bytes): 2345
Incremental data Size (bytes): 600
`,
},
{
@@ -372,8 +372,13 @@ func describeCSISnapshotsRestoresInSF(d *StructuredDescriber, restoreVolInfo []v
"dataMover": info.SnapshotDataMovementInfo.DataMover,
"uploaderType": info.SnapshotDataMovementInfo.UploaderType,
}
if info.SnapshotDataMovementInfo.RestoreType != "" {
dmInfo["restoreType"] = info.SnapshotDataMovementInfo.RestoreType
if info.RestoreType != "" {
restoreType := info.RestoreType
if info.FallbackFull {
restoreType += " (fallen back to Full)"
}
dmInfo["restoreType"] = restoreType
}
if info.SnapshotDataMovementInfo.Size > 0 {
dmInfo["size"] = info.SnapshotDataMovementInfo.Size
@@ -473,13 +473,13 @@ func TestDescribeRestoreCSISnapshotsInSF_NoData(t *testing.T) {
SnapshotDataMoved: true,
PVCName: "pvc-3",
PVCNamespace: "ns-3",
RestoreType: "Incremental",
SnapshotDataMovementInfo: &volume.RestoreSnapshotDataMovementInfo{
OperationID: "op-3",
DataMover: "velero",
UploaderType: "kopia",
Size: 1234,
IncrementalSize: ptr.To(int64(500)),
RestoreType: "Incremental",
},
},
},
@@ -499,6 +499,41 @@ func TestDescribeRestoreCSISnapshotsInSF_NoData(t *testing.T) {
},
},
},
{
name: "data movement entry, with details, fallback to full",
inputVolInfoList: []volume.RestoreVolumeInfo{
{
RestoreMethod: volume.CSISnapshot,
SnapshotDataMoved: true,
PVCName: "pvc-4",
PVCNamespace: "ns-4",
RestoreType: "Incremental",
FallbackFull: true,
SnapshotDataMovementInfo: &volume.RestoreSnapshotDataMovementInfo{
OperationID: "op-4",
DataMover: "velero",
UploaderType: "kopia",
Size: 2345,
IncrementalSize: ptr.To(int64(600)),
},
},
},
details: true,
expect: map[string]any{
"csiSnapshotRestores": map[string]any{
"ns-4/pvc-4": map[string]any{
"dataMovement": map[string]any{
"operationID": "op-4",
"dataMover": "velero",
"uploaderType": "kopia",
"size": int64(2345),
"incrementalSize": int64(600),
"restoreType": "Incremental (fallen back to Full)",
},
},
},
},
},
{
name: "data movement entry, no details",
inputVolInfoList: []volume.RestoreVolumeInfo{