issue 6695: add backup description for data mover

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2023-11-27 16:19:34 +08:00
parent 1815c1691f
commit 8ab0c017a9
4 changed files with 89 additions and 29 deletions
+13 -5
View File
@@ -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")
}
}
+27 -7
View File
@@ -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
`,
},
}
@@ -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"
}
}
@@ -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",
},
},
},