From 7cb614789c394484226882a67a3e037213abc739 Mon Sep 17 00:00:00 2001 From: Marcel Haupt Date: Wed, 4 Aug 2021 06:53:06 +0200 Subject: [PATCH] =?UTF-8?q?Restic=20Backup:=20Add=20check=20if=20Pod=20is?= =?UTF-8?q?=20successful=20or=20failed=20for=20emptyDir.=E2=80=A6=20(#3993?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Restic Backup: Add check if Pod is successful or failed for emptyDir. Fix #3812 * Add changelog Signed-off-by: mahaupt --- changelogs/unreleased/3993-mahaupt | 1 + pkg/restic/backupper.go | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/unreleased/3993-mahaupt diff --git a/changelogs/unreleased/3993-mahaupt b/changelogs/unreleased/3993-mahaupt new file mode 100644 index 000000000..9e0312c2b --- /dev/null +++ b/changelogs/unreleased/3993-mahaupt @@ -0,0 +1 @@ +Fix restic error when volume is emptyDir and Pod not running diff --git a/pkg/restic/backupper.go b/pkg/restic/backupper.go index 03e64f84c..cb8e8569a 100644 --- a/pkg/restic/backupper.go +++ b/pkg/restic/backupper.go @@ -157,6 +157,11 @@ func (b *backupper) BackupPodVolumes(backup *velerov1api.Backup, pod *corev1api. continue } + // emptyDir volumes on finished pods are not supported because the volume is already gone and would result in an error + if (pod.Status.Phase == corev1api.PodSucceeded || pod.Status.Phase == corev1api.PodFailed) && volume.EmptyDir != nil { + continue + } + volumeBackup := newPodVolumeBackup(backup, pod, volume, repo.Spec.ResticIdentifier, pvc) if volumeBackup, err = b.repoManager.veleroClient.VeleroV1().PodVolumeBackups(volumeBackup.Namespace).Create(context.TODO(), volumeBackup, metav1.CreateOptions{}); err != nil { errs = append(errs, err)