From 9be8eb0c6d39e2030c9928625fcf5bfb73232bf5 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Tue, 19 Dec 2023 17:12:34 +0800 Subject: [PATCH] Don't generate empty structure. VolumeInfo contains several sub-structures. They are filled for different scenarios. Do not generate empty structure for the not filled sub-structures. Signed-off-by: Xun Jiang --- internal/volume/volumes_information.go | 59 ++++++++++++------- internal/volume/volumes_information_test.go | 44 ++++++++------ pkg/cmd/util/output/backup_describer.go | 10 ++-- pkg/cmd/util/output/backup_describer_test.go | 40 +++++++++---- .../output/backup_structured_describer.go | 4 +- .../backup_structured_describer_test.go | 40 +++++++++---- pkg/restore/restore_test.go | 10 ++-- 7 files changed, 132 insertions(+), 75 deletions(-) diff --git a/internal/volume/volumes_information.go b/internal/volume/volumes_information.go index 64fbcb07b..ad414db58 100644 --- a/internal/volume/volumes_information.go +++ b/internal/volume/volumes_information.go @@ -42,6 +42,10 @@ const ( CSISnapshot VolumeBackupMethod = "CSISnapshot" ) +const ( + FieldValueIsUnknown string = "unknown" +) + type VolumeInfo struct { // The PVC's name. PVCName string `json:"pvcName,omitempty"` @@ -72,14 +76,11 @@ type VolumeInfo struct { // Snapshot starts timestamp. StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"` - // The Async Operation's ID. - OperationID string `json:"operationID,omitempty"` - - CSISnapshotInfo CSISnapshotInfo `json:"csiSnapshotInfo,omitempty"` - SnapshotDataMovementInfo SnapshotDataMovementInfo `json:"snapshotDataMovementInfo,omitempty"` - NativeSnapshotInfo NativeSnapshotInfo `json:"nativeSnapshotInfo,omitempty"` - PVBInfo PodVolumeBackupInfo `json:"pvbInfo,omitempty"` - PVInfo PVInfo `json:"pvInfo,omitempty"` + CSISnapshotInfo *CSISnapshotInfo `json:"csiSnapshotInfo,omitempty"` + SnapshotDataMovementInfo *SnapshotDataMovementInfo `json:"snapshotDataMovementInfo,omitempty"` + NativeSnapshotInfo *NativeSnapshotInfo `json:"nativeSnapshotInfo,omitempty"` + PVBInfo *PodVolumeBackupInfo `json:"pvbInfo,omitempty"` + PVInfo *PVInfo `json:"pvInfo,omitempty"` } // CSISnapshotInfo is used for displaying the CSI snapshot status @@ -95,6 +96,9 @@ type CSISnapshotInfo struct { // The name of the VolumeSnapshotContent. VSCName string `json:"vscName"` + + // The Async Operation's ID. + OperationID string `json:"operationID"` } // SnapshotDataMovementInfo is used for displaying the snapshot data mover status. @@ -112,6 +116,9 @@ type SnapshotDataMovementInfo struct { // It's the filesystem repository's snapshot ID. SnapshotHandle string `json:"snapshotHandle"` + + // The Async Operation's ID. + OperationID string `json:"operationID"` } // NativeSnapshotInfo is used for displaying the Velero native snapshot status. @@ -244,7 +251,7 @@ func (v *VolumesInformation) generateVolumeInfoForSkippedPV() { SnapshotDataMoved: false, Skipped: true, SkippedReason: skippedReason, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: string(pvcPVInfo.PV.Spec.PersistentVolumeReclaimPolicy), Labels: pvcPVInfo.PV.Labels, }, @@ -277,13 +284,13 @@ func (v *VolumesInformation) generateVolumeInfoForVeleroNativeSnapshot() { PVName: pvcPVInfo.PV.Name, SnapshotDataMoved: false, Skipped: false, - NativeSnapshotInfo: NativeSnapshotInfo{ + NativeSnapshotInfo: &NativeSnapshotInfo{ SnapshotHandle: nativeSnapshot.Status.ProviderSnapshotID, VolumeType: nativeSnapshot.Spec.VolumeType, VolumeAZ: nativeSnapshot.Spec.VolumeAZ, IOPS: strconv.FormatInt(iops, 10), }, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: string(pvcPVInfo.PV.Spec.PersistentVolumeReclaimPolicy), Labels: pvcPVInfo.PV.Labels, }, @@ -372,15 +379,15 @@ func (v *VolumesInformation) generateVolumeInfoForCSIVolumeSnapshot() { Skipped: false, SnapshotDataMoved: false, PreserveLocalSnapshot: true, - OperationID: operation.Spec.OperationID, StartTimestamp: &(volumeSnapshot.CreationTimestamp), - CSISnapshotInfo: CSISnapshotInfo{ + CSISnapshotInfo: &CSISnapshotInfo{ VSCName: *volumeSnapshot.Status.BoundVolumeSnapshotContentName, Size: size, Driver: volumeSnapshotClass.Driver, SnapshotHandle: snapshotHandle, + OperationID: operation.Spec.OperationID, }, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: string(pvcPVInfo.PV.Spec.PersistentVolumeReclaimPolicy), Labels: pvcPVInfo.PV.Labels, }, @@ -406,7 +413,7 @@ func (v *VolumesInformation) generateVolumeInfoFromPVB() { SnapshotDataMoved: false, Skipped: false, StartTimestamp: pvb.Status.StartTimestamp, - PVBInfo: PodVolumeBackupInfo{ + PVBInfo: &PodVolumeBackupInfo{ SnapshotHandle: pvb.Status.SnapshotID, Size: pvb.Status.Progress.TotalBytes, UploaderType: pvb.Spec.UploaderType, @@ -435,7 +442,7 @@ func (v *VolumesInformation) generateVolumeInfoFromPVB() { volumeInfo.PVCName = pvcPVInfo.PVCName volumeInfo.PVCNamespace = pvcPVInfo.PVCNamespace volumeInfo.PVName = pvcPVInfo.PV.Name - volumeInfo.PVInfo = PVInfo{ + volumeInfo.PVInfo = &PVInfo{ ReclaimPolicy: string(pvcPVInfo.PV.Spec.PersistentVolumeReclaimPolicy), Labels: pvcPVInfo.PV.Labels, } @@ -498,6 +505,11 @@ func (v *VolumesInformation) generateVolumeInfoFromDataUpload() { } if pvcPVInfo := v.retrievePvcPvInfo("", operation.Spec.ResourceIdentifier.Name, operation.Spec.ResourceIdentifier.Namespace); pvcPVInfo != nil { + dataMover := "velero" + if dataUpload.Spec.DataMover != "" { + dataMover = dataUpload.Spec.DataMover + } + volumeInfo := &VolumeInfo{ BackupMethod: CSISnapshot, PVCName: pvcPVInfo.PVCName, @@ -505,16 +517,19 @@ func (v *VolumesInformation) generateVolumeInfoFromDataUpload() { PVName: pvcPVInfo.PV.Name, SnapshotDataMoved: true, Skipped: false, - OperationID: operation.Spec.OperationID, StartTimestamp: operation.Status.Created, - CSISnapshotInfo: CSISnapshotInfo{ - Driver: driverUsedByVSClass, + CSISnapshotInfo: &CSISnapshotInfo{ + SnapshotHandle: FieldValueIsUnknown, + VSCName: FieldValueIsUnknown, + OperationID: FieldValueIsUnknown, + Driver: driverUsedByVSClass, }, - SnapshotDataMovementInfo: SnapshotDataMovementInfo{ - DataMover: dataUpload.Spec.DataMover, + SnapshotDataMovementInfo: &SnapshotDataMovementInfo{ + DataMover: dataMover, UploaderType: "kopia", + OperationID: operation.Spec.OperationID, }, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: string(pvcPVInfo.PV.Spec.PersistentVolumeReclaimPolicy), Labels: pvcPVInfo.PV.Labels, }, diff --git a/internal/volume/volumes_information_test.go b/internal/volume/volumes_information_test.go index 45051514d..fcd66a50d 100644 --- a/internal/volume/volumes_information_test.go +++ b/internal/volume/volumes_information_test.go @@ -103,7 +103,7 @@ func TestGenerateVolumeInfoForSkippedPV(t *testing.T) { PVName: "testPV", Skipped: true, SkippedReason: "CSI: skipped for PodVolumeBackup", - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: "Delete", Labels: map[string]string{ "a": "b", @@ -229,13 +229,13 @@ func TestGenerateVolumeInfoForVeleroNativeSnapshot(t *testing.T) { PVCNamespace: "velero", PVName: "testPV", BackupMethod: NativeSnapshot, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: "Delete", Labels: map[string]string{ "a": "b", }, }, - NativeSnapshotInfo: NativeSnapshotInfo{ + NativeSnapshotInfo: &NativeSnapshotInfo{ SnapshotHandle: "pvc-b31e3386-4bbb-4937-95d-7934cd62-b0a1-494b-95d7-0687440e8d0c", VolumeType: "ssd", VolumeAZ: "us-central1-a", @@ -411,16 +411,16 @@ func TestGenerateVolumeInfoForCSIVolumeSnapshot(t *testing.T) { PVCNamespace: "velero", PVName: "testPV", BackupMethod: CSISnapshot, - OperationID: "testID", StartTimestamp: &now, PreserveLocalSnapshot: true, - CSISnapshotInfo: CSISnapshotInfo{ + CSISnapshotInfo: &CSISnapshotInfo{ Driver: "pd.csi.storage.gke.io", SnapshotHandle: "testSnapshotHandle", Size: 107374182400, VSCName: "testContent", + OperationID: "testID", }, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: "Delete", Labels: map[string]string{ "a": "b", @@ -495,7 +495,7 @@ func TestGenerateVolumeInfoFromPVB(t *testing.T) { PVCNamespace: "", PVName: "", BackupMethod: PodVolumeBackup, - PVBInfo: PodVolumeBackupInfo{ + PVBInfo: &PodVolumeBackupInfo{ PodName: "testPod", PodNamespace: "velero", }, @@ -567,11 +567,11 @@ func TestGenerateVolumeInfoFromPVB(t *testing.T) { PVCNamespace: "velero", PVName: "testPV", BackupMethod: PodVolumeBackup, - PVBInfo: PodVolumeBackupInfo{ + PVBInfo: &PodVolumeBackupInfo{ PodName: "testPod", PodNamespace: "velero", }, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: string(corev1api.PersistentVolumeReclaimDelete), Labels: map[string]string{"a": "b"}, }, @@ -729,12 +729,18 @@ func TestGenerateVolumeInfoFromDataUpload(t *testing.T) { PVName: "testPV", BackupMethod: CSISnapshot, SnapshotDataMoved: true, - OperationID: "testOperation", - SnapshotDataMovementInfo: SnapshotDataMovementInfo{ + CSISnapshotInfo: &CSISnapshotInfo{ + SnapshotHandle: FieldValueIsUnknown, + VSCName: FieldValueIsUnknown, + OperationID: FieldValueIsUnknown, + Size: 0, + }, + SnapshotDataMovementInfo: &SnapshotDataMovementInfo{ DataMover: "velero", UploaderType: "kopia", + OperationID: "testOperation", }, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: string(corev1api.PersistentVolumeReclaimDelete), Labels: map[string]string{"a": "b"}, }, @@ -796,16 +802,20 @@ func TestGenerateVolumeInfoFromDataUpload(t *testing.T) { PVName: "testPV", BackupMethod: CSISnapshot, SnapshotDataMoved: true, - OperationID: "testOperation", StartTimestamp: &now, - CSISnapshotInfo: CSISnapshotInfo{ - Driver: "pd.csi.storage.gke.io", + CSISnapshotInfo: &CSISnapshotInfo{ + VSCName: FieldValueIsUnknown, + SnapshotHandle: FieldValueIsUnknown, + OperationID: FieldValueIsUnknown, + Size: 0, + Driver: "pd.csi.storage.gke.io", }, - SnapshotDataMovementInfo: SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &SnapshotDataMovementInfo{ DataMover: "velero", UploaderType: "kopia", + OperationID: "testOperation", }, - PVInfo: PVInfo{ + PVInfo: &PVInfo{ ReclaimPolicy: string(corev1api.PersistentVolumeReclaimDelete), Labels: map[string]string{"a": "b"}, }, diff --git a/pkg/cmd/util/output/backup_describer.go b/pkg/cmd/util/output/backup_describer.go index 664684cf7..4dfcfc389 100644 --- a/pkg/cmd/util/output/backup_describer.go +++ b/pkg/cmd/util/output/backup_describer.go @@ -513,7 +513,7 @@ func retrieveNativeSnapshotLegacy(ctx context.Context, kbClient kbclient.Client, for _, snap := range snapshots { volumeInfo := volume.VolumeInfo{ PVName: snap.Spec.PersistentVolumeName, - NativeSnapshotInfo: volume.NativeSnapshotInfo{ + NativeSnapshotInfo: &volume.NativeSnapshotInfo{ SnapshotHandle: snap.Status.ProviderSnapshotID, VolumeType: snap.Spec.VolumeType, VolumeAZ: snap.Spec.VolumeAZ, @@ -567,7 +567,7 @@ func retrieveCSISnapshotLegacy(ctx context.Context, kbClient kbclient.Client, ba for _, vsc := range vscList { volInfo := volume.VolumeInfo{ PreserveLocalSnapshot: true, - CSISnapshotInfo: volume.CSISnapshotInfo{ + CSISnapshotInfo: &volume.CSISnapshotInfo{ VSCName: vsc.Name, Driver: vsc.Spec.Driver, }, @@ -663,8 +663,8 @@ func describeLocalSnapshot(d *Describer, details bool, info *volume.VolumeInfo) if details { d.Printf("\t\t\tSnapshot:\n") - if !info.SnapshotDataMoved && info.OperationID != "" { - d.Printf("\t\t\t\tOperation ID: %s\n", info.OperationID) + if !info.SnapshotDataMoved && info.CSISnapshotInfo.OperationID != "" { + d.Printf("\t\t\t\tOperation ID: %s\n", info.CSISnapshotInfo.OperationID) } d.Printf("\t\t\t\tSnapshot Content Name: %s\n", info.CSISnapshotInfo.VSCName) @@ -683,7 +683,7 @@ func describeDataMovement(d *Describer, details bool, info *volume.VolumeInfo) { if details { d.Printf("\t\t\tData Movement:\n") - d.Printf("\t\t\t\tOperation ID: %s\n", info.OperationID) + d.Printf("\t\t\t\tOperation ID: %s\n", info.SnapshotDataMovementInfo.OperationID) dataMover := "velero" if info.SnapshotDataMovementInfo.DataMover != "" { diff --git a/pkg/cmd/util/output/backup_describer_test.go b/pkg/cmd/util/output/backup_describer_test.go index a43ea9584..b34d3558b 100644 --- a/pkg/cmd/util/output/backup_describer_test.go +++ b/pkg/cmd/util/output/backup_describer_test.go @@ -1,3 +1,19 @@ +/* +Copyright the Velero contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package output import ( @@ -320,7 +336,7 @@ func TestDescribeNativeSnapshots(t *testing.T) { { BackupMethod: volume.NativeSnapshot, PVName: "pv-1", - NativeSnapshotInfo: volume.NativeSnapshotInfo{ + NativeSnapshotInfo: &volume.NativeSnapshotInfo{ SnapshotHandle: "snapshot-1", VolumeType: "ebs", VolumeAZ: "us-east-2", @@ -338,7 +354,7 @@ func TestDescribeNativeSnapshots(t *testing.T) { { BackupMethod: volume.NativeSnapshot, PVName: "pv-1", - NativeSnapshotInfo: volume.NativeSnapshotInfo{ + NativeSnapshotInfo: &volume.NativeSnapshotInfo{ SnapshotHandle: "snapshot-1", VolumeType: "ebs", VolumeAZ: "us-east-2", @@ -405,12 +421,12 @@ func TestCSISnapshots(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-1", PreserveLocalSnapshot: true, - OperationID: "fake-operation-1", - CSISnapshotInfo: volume.CSISnapshotInfo{ + CSISnapshotInfo: &volume.CSISnapshotInfo{ SnapshotHandle: "snapshot-1", Size: 1024, Driver: "fake-driver", VSCName: "vsc-1", + OperationID: "fake-operation-1", }, }, }, @@ -426,12 +442,12 @@ func TestCSISnapshots(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-2", PreserveLocalSnapshot: true, - OperationID: "fake-operation-2", - CSISnapshotInfo: volume.CSISnapshotInfo{ + CSISnapshotInfo: &volume.CSISnapshotInfo{ SnapshotHandle: "snapshot-2", Size: 1024, Driver: "fake-driver", VSCName: "vsc-2", + OperationID: "fake-operation-2", }, }, }, @@ -453,11 +469,11 @@ func TestCSISnapshots(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-3", SnapshotDataMoved: true, - OperationID: "fake-operation-3", - SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &volume.SnapshotDataMovementInfo{ DataMover: "velero", UploaderType: "fake-uploader", SnapshotHandle: "fake-repo-id-3", + OperationID: "fake-operation-3", }, }, }, @@ -473,11 +489,11 @@ func TestCSISnapshots(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-4", SnapshotDataMoved: true, - OperationID: "fake-operation-4", - SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &volume.SnapshotDataMovementInfo{ DataMover: "velero", UploaderType: "fake-uploader", SnapshotHandle: "fake-repo-id-4", + OperationID: "fake-operation-4", }, }, }, @@ -497,10 +513,10 @@ func TestCSISnapshots(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-5", SnapshotDataMoved: true, - OperationID: "fake-operation-5", - SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &volume.SnapshotDataMovementInfo{ UploaderType: "fake-uploader", SnapshotHandle: "fake-repo-id-5", + OperationID: "fake-operation-5", }, }, }, diff --git a/pkg/cmd/util/output/backup_structured_describer.go b/pkg/cmd/util/output/backup_structured_describer.go index 1f6e7d540..28d1553e3 100644 --- a/pkg/cmd/util/output/backup_structured_describer.go +++ b/pkg/cmd/util/output/backup_structured_describer.go @@ -425,7 +425,7 @@ func describeLocalSnapshotInSF(details bool, info *volume.VolumeInfo, snapshotDe localSnapshot := make(map[string]interface{}) if !info.SnapshotDataMoved { - localSnapshot["operationID"] = info.OperationID + localSnapshot["operationID"] = info.CSISnapshotInfo.OperationID } localSnapshot["snapshotContentName"] = info.CSISnapshotInfo.VSCName @@ -446,7 +446,7 @@ func describeDataMovementInSF(details bool, info *volume.VolumeInfo, snapshotDet if details { dataMovement := make(map[string]interface{}) - dataMovement["operationID"] = info.OperationID + dataMovement["operationID"] = info.SnapshotDataMovementInfo.OperationID dataMover := "velero" if info.SnapshotDataMovementInfo.DataMover != "" { diff --git a/pkg/cmd/util/output/backup_structured_describer_test.go b/pkg/cmd/util/output/backup_structured_describer_test.go index 4dcadacd9..8e4321b6e 100644 --- a/pkg/cmd/util/output/backup_structured_describer_test.go +++ b/pkg/cmd/util/output/backup_structured_describer_test.go @@ -1,3 +1,19 @@ +/* +Copyright the Velero contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package output import ( @@ -279,7 +295,7 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) { { BackupMethod: volume.NativeSnapshot, PVName: "pv-1", - NativeSnapshotInfo: volume.NativeSnapshotInfo{ + NativeSnapshotInfo: &volume.NativeSnapshotInfo{ SnapshotHandle: "snapshot-1", VolumeType: "ebs", VolumeAZ: "us-east-2", @@ -299,7 +315,7 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) { { BackupMethod: volume.NativeSnapshot, PVName: "pv-1", - NativeSnapshotInfo: volume.NativeSnapshotInfo{ + NativeSnapshotInfo: &volume.NativeSnapshotInfo{ SnapshotHandle: "snapshot-1", VolumeType: "ebs", VolumeAZ: "us-east-2", @@ -365,12 +381,12 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-1", PreserveLocalSnapshot: true, - OperationID: "fake-operation-1", - CSISnapshotInfo: volume.CSISnapshotInfo{ + CSISnapshotInfo: &volume.CSISnapshotInfo{ SnapshotHandle: "snapshot-1", Size: 1024, Driver: "fake-driver", VSCName: "vsc-1", + OperationID: "fake-operation-1", }, }, }, @@ -389,12 +405,12 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-2", PreserveLocalSnapshot: true, - OperationID: "fake-operation-2", - CSISnapshotInfo: volume.CSISnapshotInfo{ + CSISnapshotInfo: &volume.CSISnapshotInfo{ SnapshotHandle: "snapshot-2", Size: 1024, Driver: "fake-driver", VSCName: "vsc-2", + OperationID: "fake-operation-2", }, }, }, @@ -420,11 +436,11 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-3", SnapshotDataMoved: true, - OperationID: "fake-operation-3", - SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &volume.SnapshotDataMovementInfo{ DataMover: "velero", UploaderType: "fake-uploader", SnapshotHandle: "fake-repo-id-3", + OperationID: "fake-operation-3", }, }, }, @@ -443,11 +459,11 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-4", SnapshotDataMoved: true, - OperationID: "fake-operation-4", - SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &volume.SnapshotDataMovementInfo{ DataMover: "velero", UploaderType: "fake-uploader", SnapshotHandle: "fake-repo-id-4", + OperationID: "fake-operation-4", }, }, }, @@ -471,10 +487,10 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) { BackupMethod: volume.CSISnapshot, PVCName: "pvc-4", SnapshotDataMoved: true, - OperationID: "fake-operation-4", - SnapshotDataMovementInfo: volume.SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &volume.SnapshotDataMovementInfo{ UploaderType: "fake-uploader", SnapshotHandle: "fake-repo-id-4", + OperationID: "fake-operation-4", }, }, }, diff --git a/pkg/restore/restore_test.go b/pkg/restore/restore_test.go index 65cfbf5a9..19022bb70 100644 --- a/pkg/restore/restore_test.go +++ b/pkg/restore/restore_test.go @@ -88,7 +88,7 @@ func TestRestorePVWithVolumeInfo(t *testing.T) { "pv-1": { BackupMethod: internalVolume.NativeSnapshot, PVName: "pv-1", - NativeSnapshotInfo: internalVolume.NativeSnapshotInfo{ + NativeSnapshotInfo: &internalVolume.NativeSnapshotInfo{ SnapshotHandle: "testSnapshotHandle", }, }, @@ -112,7 +112,7 @@ func TestRestorePVWithVolumeInfo(t *testing.T) { "pv-1": { BackupMethod: internalVolume.PodVolumeBackup, PVName: "pv-1", - PVBInfo: internalVolume.PodVolumeBackupInfo{ + PVBInfo: &internalVolume.PodVolumeBackupInfo{ SnapshotHandle: "testSnapshotHandle", Size: 100, NodeName: "testNode", @@ -139,7 +139,7 @@ func TestRestorePVWithVolumeInfo(t *testing.T) { BackupMethod: internalVolume.CSISnapshot, SnapshotDataMoved: false, PVName: "pv-1", - CSISnapshotInfo: internalVolume.CSISnapshotInfo{ + CSISnapshotInfo: &internalVolume.CSISnapshotInfo{ Driver: "pd.csi.storage.gke.io", }, }, @@ -164,10 +164,10 @@ func TestRestorePVWithVolumeInfo(t *testing.T) { BackupMethod: internalVolume.CSISnapshot, SnapshotDataMoved: true, PVName: "pv-1", - CSISnapshotInfo: internalVolume.CSISnapshotInfo{ + CSISnapshotInfo: &internalVolume.CSISnapshotInfo{ Driver: "pd.csi.storage.gke.io", }, - SnapshotDataMovementInfo: internalVolume.SnapshotDataMovementInfo{ + SnapshotDataMovementInfo: &internalVolume.SnapshotDataMovementInfo{ DataMover: "velero", }, },