We don't want to snapshot the same volume multiple time (subpath)

This commit is contained in:
Jean-Marc ANDRE 2023-04-27 15:37:15 +02:00
parent e19e1775e8
commit bf2d50c41a

View File

@ -257,9 +257,10 @@ func (r *BackupSessionReconciler) createVolumeFromSnapshot(vs *volumesnapshotv1.
func (r *BackupSessionReconciler) snapshotVolumes(vms []corev1.VolumeMount, podSpec *corev1.PodSpec) (err error) {
// We snapshot/check all the volumes. If at least one of the snapshot is not ready to use. We reschedule.
alreadySnapshoted := make(map[string]struct{})
for _, vm := range vms {
for i, volume := range podSpec.Volumes {
if vm.Name == volume.Name {
if _, done := alreadySnapshoted[volume.Name]; done == false && vm.Name == volume.Name {
var vs *volumesnapshotv1.VolumeSnapshot
vs, err = r.snapshotVolume(volume)
if IsNotReadyToUse(err) {
@ -273,6 +274,7 @@ func (r *BackupSessionReconciler) snapshotVolumes(vms []corev1.VolumeMount, podS
}
if vs != nil {
// The snapshot is ready. We create a PVC from it.
alreadySnapshoted[volume.Name] = struct{}{}
backupPVCName, err := r.createVolumeFromSnapshot(vs)
if err != nil {
r.Log.Error(err, "unable to create volume from snapshot", "vs", vs)