From 828e28aa43b08de948d565f902a7d5c41826f220 Mon Sep 17 00:00:00 2001 From: Ming Date: Tue, 2 Aug 2022 10:20:53 +0000 Subject: [PATCH] Fix restic backups to multiple backup storage locations bug Signed-off-by: Ming --- changelogs/unreleased/5172-qiuming-best | 1 + pkg/controller/pod_volume_backup_controller.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/5172-qiuming-best diff --git a/changelogs/unreleased/5172-qiuming-best b/changelogs/unreleased/5172-qiuming-best new file mode 100644 index 000000000..fa57d3d30 --- /dev/null +++ b/changelogs/unreleased/5172-qiuming-best @@ -0,0 +1 @@ +Fix restic backups to multiple backup storage locations bug diff --git a/pkg/controller/pod_volume_backup_controller.go b/pkg/controller/pod_volume_backup_controller.go index 9cb6a3ae2..8bce92ed7 100644 --- a/pkg/controller/pod_volume_backup_controller.go +++ b/pkg/controller/pod_volume_backup_controller.go @@ -241,7 +241,7 @@ func (r *PodVolumeBackupReconciler) getParentSnapshot(ctx context.Context, log l // Go through all the podvolumebackups for the PVC and look for the most // recent completed one to use as the parent. - var mostRecentPVB *velerov1api.PodVolumeBackup + var mostRecentPVB velerov1api.PodVolumeBackup for _, pvb := range pvbList.Items { if pvb.Status.Phase != velerov1api.PodVolumeBackupPhaseCompleted { continue @@ -258,12 +258,12 @@ func (r *PodVolumeBackupReconciler) getParentSnapshot(ctx context.Context, log l continue } - if mostRecentPVB == nil || pvb.Status.StartTimestamp.After(mostRecentPVB.Status.StartTimestamp.Time) { - mostRecentPVB = &pvb + if mostRecentPVB.Status == (velerov1api.PodVolumeBackupStatus{}) || pvb.Status.StartTimestamp.After(mostRecentPVB.Status.StartTimestamp.Time) { + mostRecentPVB = pvb } } - if mostRecentPVB == nil { + if mostRecentPVB.Status == (velerov1api.PodVolumeBackupStatus{}) { log.Info("No completed PodVolumeBackup found for PVC") return "" }