diff --git a/pkg/cmd/util/output/backup_describer.go b/pkg/cmd/util/output/backup_describer.go index 77a8305fc..5cadbcef6 100644 --- a/pkg/cmd/util/output/backup_describer.go +++ b/pkg/cmd/util/output/backup_describer.go @@ -507,7 +507,6 @@ func describeCSISnapshots(d *Describer, details bool, infos []*volume.VolumeInfo func describeCSISnapshot(d *Describer, details bool, info *volume.VolumeInfo) { d.Printf("\t\t%s:\n", info.PVCName) - d.Printf("\t\t\tOperation ID: %s\n", info.OperationID) describeLocalSnapshot(d, details, info) describeDataMovement(d, details, info) @@ -520,12 +519,16 @@ func describeLocalSnapshot(d *Describer, details bool, info *volume.VolumeInfo) if details { d.Printf("\t\t\tSnapshot:\n") + if !info.SnapshotDataMoved { + d.Printf("\t\t\t\tOperation ID: %s\n", info.OperationID) + } + d.Printf("\t\t\t\tSnapshot Content Name: %s\n", info.CSISnapshotInfo.VSCName) d.Printf("\t\t\t\tStorage Snapshot ID: %s\n", info.CSISnapshotInfo.SnapshotHandle) d.Printf("\t\t\t\tSnapshot Size (bytes): %d\n", info.CSISnapshotInfo.Size) d.Printf("\t\t\t\tCSI Driver: %s\n", info.CSISnapshotInfo.Driver) } else { - d.Printf("\t\t\tSnapshot: %s\n", "specify --details for more information") + d.Printf("\t\t\tSnapshot: %s\n", "included, specify --details for more information") } } @@ -536,11 +539,16 @@ func describeDataMovement(d *Describer, details bool, info *volume.VolumeInfo) { if details { d.Printf("\t\t\tData Movement:\n") - d.Printf("\t\t\t\tData Mover: %s\n", info.SnapshotDataMovementInfo.DataMover) + d.Printf("\t\t\t\tOperation ID: %s\n", info.OperationID) + + dataMover := "velero" + if info.SnapshotDataMovementInfo.DataMover != "" { + dataMover = info.SnapshotDataMovementInfo.DataMover + } + d.Printf("\t\t\t\tData Mover: %s\n", dataMover) d.Printf("\t\t\t\tUploader Type: %s\n", info.SnapshotDataMovementInfo.UploaderType) - d.Printf("\t\t\t\tRepository Snapshot ID: %s\n", info.SnapshotDataMovementInfo.SnapshotHandle) } else { - d.Printf("\t\t\tData Movement: %s\n", "specify --details for more information") + d.Printf("\t\t\tData Movement: %s\n", "included, specify --details for more information") } } diff --git a/pkg/cmd/util/output/backup_describer_test.go b/pkg/cmd/util/output/backup_describer_test.go index 7f547d4f5..ab9c5471f 100644 --- a/pkg/cmd/util/output/backup_describer_test.go +++ b/pkg/cmd/util/output/backup_describer_test.go @@ -402,8 +402,7 @@ func TestCSISnapshots(t *testing.T) { }, expect: ` CSI Snapshots: pvc-1: - Operation ID: fake-operation-1 - Snapshot: specify --details for more information + Snapshot: included, specify --details for more information `, }, { @@ -425,8 +424,8 @@ func TestCSISnapshots(t *testing.T) { inputDetails: true, expect: ` CSI Snapshots: pvc-2: - Operation ID: fake-operation-2 Snapshot: + Operation ID: fake-operation-2 Snapshot Content Name: vsc-2 Storage Snapshot ID: snapshot-2 Snapshot Size (bytes): 1024 @@ -450,8 +449,7 @@ func TestCSISnapshots(t *testing.T) { }, expect: ` CSI Snapshots: pvc-3: - Operation ID: fake-operation-3 - Data Movement: specify --details for more information + Data Movement: included, specify --details for more information `, }, { @@ -472,11 +470,33 @@ func TestCSISnapshots(t *testing.T) { inputDetails: true, expect: ` CSI Snapshots: pvc-4: - Operation ID: fake-operation-4 Data Movement: + Operation ID: fake-operation-4 + Data Mover: velero + Uploader Type: fake-uploader +`, + }, + { + name: "details, data movement, data mover is empty", + volumeInfo: []*volume.VolumeInfo{ + { + BackupMethod: volume.CSISnapshot, + PVCName: "pvc-5", + SnapshotDataMoved: true, + OperationID: "fake-operation-5", + SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + UploaderType: "fake-uploader", + SnapshotHandle: "fake-repo-id-5", + }, + }, + }, + inputDetails: true, + expect: ` CSI Snapshots: + pvc-5: + Data Movement: + Operation ID: fake-operation-5 Data Mover: velero Uploader Type: fake-uploader - Repository Snapshot ID: fake-repo-id-4 `, }, } diff --git a/pkg/cmd/util/output/backup_structured_describer.go b/pkg/cmd/util/output/backup_structured_describer.go index 6578dedab..4d4095c18 100644 --- a/pkg/cmd/util/output/backup_structured_describer.go +++ b/pkg/cmd/util/output/backup_structured_describer.go @@ -329,9 +329,7 @@ func describeBackupVolumesInSF(ctx context.Context, kbClient kbclient.Client, ba describeNativeSnapshotsInSF(details, nativeSnapshots, backupVolumes) - csiSnapshotDetails := make(map[string]interface{}) - describeCSISnapshotsInSF(details, csiSnapshots, csiSnapshotDetails) - backupVolumes["csiSnapshots"] = csiSnapshotDetails + describeCSISnapshotsInSF(details, csiSnapshots, backupVolumes) describePodVolumeBackupsInSF(podVolumeBackupCRs, details, backupVolumes) @@ -384,7 +382,6 @@ func describeCSISnapshotsInSF(details bool, infos []*volume.VolumeInfo, backupVo func describeCSISnapshotInSF(details bool, info *volume.VolumeInfo, snapshotDetails map[string]interface{}) { snapshotDetail := make(map[string]interface{}) - snapshotDetail["operationID"] = info.OperationID describeLocalSnapshotInSF(details, info, snapshotDetail) describeDataMovementInSF(details, info, snapshotDetail) @@ -400,6 +397,11 @@ func describeLocalSnapshotInSF(details bool, info *volume.VolumeInfo, snapshotDe if details { localSnapshot := make(map[string]interface{}) + + if !info.SnapshotDataMoved { + localSnapshot["operationID"] = info.OperationID + } + localSnapshot["snapshotContentName"] = info.CSISnapshotInfo.VSCName localSnapshot["storageSnapshotID"] = info.CSISnapshotInfo.SnapshotHandle localSnapshot["snapshotSize(bytes)"] = info.CSISnapshotInfo.Size @@ -407,7 +409,7 @@ func describeLocalSnapshotInSF(details bool, info *volume.VolumeInfo, snapshotDe snapshotDetail["snapshot"] = localSnapshot } else { - snapshotDetail["snapshot"] = "specify --details for more information" + snapshotDetail["snapshot"] = "included, specify --details for more information" } } @@ -418,13 +420,19 @@ func describeDataMovementInSF(details bool, info *volume.VolumeInfo, snapshotDet if details { dataMovement := make(map[string]interface{}) - dataMovement["dataMover"] = info.SnapshotDataMovementInfo.DataMover + dataMovement["operationID"] = info.OperationID + + dataMover := "velero" + if info.SnapshotDataMovementInfo.DataMover != "" { + dataMover = info.SnapshotDataMovementInfo.DataMover + } + dataMovement["dataMover"] = dataMover + dataMovement["uploaderType"] = info.SnapshotDataMovementInfo.UploaderType - dataMovement["repositorySnapshotID"] = info.SnapshotDataMovementInfo.SnapshotHandle snapshotDetail["dataMovement"] = dataMovement } else { - snapshotDetail["dataMovement"] = "specify --details for more information" + snapshotDetail["dataMovement"] = "included, specify --details for more information" } } diff --git a/pkg/cmd/util/output/backup_structured_describer_test.go b/pkg/cmd/util/output/backup_structured_describer_test.go index 4007a35fe..24b3bca49 100644 --- a/pkg/cmd/util/output/backup_structured_describer_test.go +++ b/pkg/cmd/util/output/backup_structured_describer_test.go @@ -361,8 +361,7 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { expect: map[string]interface{}{ "csiSnapshots": map[string]interface{}{ "pvc-1": map[string]interface{}{ - "operationID": "fake-operation-1", - "snapshot": "specify --details for more information", + "snapshot": "included, specify --details for more information", }, }, }, @@ -387,8 +386,8 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { expect: map[string]interface{}{ "csiSnapshots": map[string]interface{}{ "pvc-2": map[string]interface{}{ - "operationID": "fake-operation-2", "snapshot": map[string]interface{}{ + "operationID": "fake-operation-2", "snapshotContentName": "vsc-2", "storageSnapshotID": "snapshot-2", "snapshotSize(bytes)": int64(1024), @@ -416,8 +415,7 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { expect: map[string]interface{}{ "csiSnapshots": map[string]interface{}{ "pvc-3": map[string]interface{}{ - "operationID": "fake-operation-3", - "dataMovement": "specify --details for more information", + "dataMovement": "included, specify --details for more information", }, }, }, @@ -441,11 +439,37 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { expect: map[string]interface{}{ "csiSnapshots": map[string]interface{}{ "pvc-4": map[string]interface{}{ - "operationID": "fake-operation-4", "dataMovement": map[string]interface{}{ - "dataMover": "velero", - "uploaderType": "fake-uploader", - "repositorySnapshotID": "fake-repo-id-4", + "operationID": "fake-operation-4", + "dataMover": "velero", + "uploaderType": "fake-uploader", + }, + }, + }, + }, + }, + { + name: "details, data movement, data mover is empty", + volumeInfo: []*volume.VolumeInfo{ + { + BackupMethod: volume.CSISnapshot, + PVCName: "pvc-4", + SnapshotDataMoved: true, + OperationID: "fake-operation-4", + SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + UploaderType: "fake-uploader", + SnapshotHandle: "fake-repo-id-4", + }, + }, + }, + inputDetails: true, + expect: map[string]interface{}{ + "csiSnapshots": map[string]interface{}{ + "pvc-4": map[string]interface{}{ + "dataMovement": map[string]interface{}{ + "operationID": "fake-operation-4", + "dataMover": "velero", + "uploaderType": "fake-uploader", }, }, },