restic backupper: ignore volumes of non-running pods (#4584)

This commit is contained in:
bynare
2022-02-16 10:34:58 +13:00
committed by GitHub
parent d1063bda7e
commit 768a30618f
2 changed files with 6 additions and 5 deletions

View File

@@ -0,0 +1 @@
Skip volumes of non-running pods when backing up

View File

@@ -153,6 +153,11 @@ func (b *backupper) BackupPodVolumes(backup *velerov1api.Backup, pod *corev1api.
}
}
// ignore non-running pods
if pod.Status.Phase != corev1api.PodRunning {
log.Warnf("Skipping volume %s in pod %s/%s - pod not running", volumeName, pod.Namespace, pod.Name)
continue
}
// hostPath volumes are not supported because they're not mounted into /var/lib/kubelet/pods, so our
// daemonset pod has no way to access their data.
isHostPath, err := isHostPathVolume(&volume, pvc, b.pvClient.PersistentVolumes())
@@ -165,11 +170,6 @@ 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
}
// volumes that are not mounted by any container should not be backed up, because
// its directory is not created
if !mountedPodVolumes.Has(volumeName) {