Skip to content

Commit e59745a

Browse files
committed
Strip PVC before saving in snapshot request ConfigMap
1 parent d966a8d commit e59745a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkg/snapshot/volumes/csi/reconcilenotstarted.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package csi
33
import (
44
"context"
55
"fmt"
6-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
76

87
"github.com/loft-sh/vcluster/pkg/snapshot/volumes"
8+
corev1 "k8s.io/api/core/v1"
9+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
910
)
1011

1112
func (s *VolumeSnapshotter) reconcileNotStarted(ctx context.Context, snapshotRequestName string, snapshotRequest *volumes.SnapshotRequest) error {
@@ -38,7 +39,15 @@ func (s *VolumeSnapshotter) reconcileNotStarted(ctx context.Context, snapshotReq
3839
s.logger.Errorf("failed to get PersistentVolumeClaim %s/%s for PersistentVolume %s: %w", pv.Spec.ClaimRef.Namespace, pv.Spec.ClaimRef.Name, pv.Name, err)
3940
continue
4041
}
41-
snapshotConfig.PersistentVolumeClaim = *pvc
42+
pvcCopy := pvc.DeepCopy()
43+
delete(pvcCopy.Annotations, "kubectl.kubernetes.io/last-applied-configuration")
44+
delete(pvcCopy.Annotations, "pv.kubernetes.io/bind-completed")
45+
delete(pvcCopy.Annotations, "pv.kubernetes.io/bound-by-controller")
46+
delete(pvcCopy.Annotations, "volume.beta.kubernetes.io/storage-provisioner")
47+
delete(pvcCopy.Annotations, "volume.kubernetes.io/storage-provisioner")
48+
pvcCopy.ManagedFields = nil
49+
pvcCopy.Status = corev1.PersistentVolumeClaimStatus{}
50+
snapshotConfig.PersistentVolumeClaim = *pvcCopy
4251

4352
if volumeSnapshotClassName, ok := pvc.Labels[volumes.SnapshotClassNameLabel]; ok {
4453
snapshotConfig.VolumeSnapshotClassName = volumeSnapshotClassName

0 commit comments

Comments
 (0)