diff --git a/pkg/controller/clone/csi-clone.go b/pkg/controller/clone/csi-clone.go index 4efbb0d723..6596ea29d0 100644 --- a/pkg/controller/clone/csi-clone.go +++ b/pkg/controller/clone/csi-clone.go @@ -106,6 +106,7 @@ func (p *CSIClonePhase) createClaim(ctx context.Context) (*corev1.PersistentVolu desiredClaim.Spec.Resources.Requests[corev1.ResourceStorage] = sourceSize cc.AddAnnotation(desiredClaim, cc.AnnPopulatorKind, cdiv1.VolumeCloneSourceRef) + cc.AddAnnotation(desiredClaim, cc.AnnExcludeFromVeleroBackup, "true") if p.OwnershipLabel != "" { AddOwnershipLabel(p.OwnershipLabel, desiredClaim, p.Owner) } diff --git a/pkg/controller/clone/csi-clone_test.go b/pkg/controller/clone/csi-clone_test.go index 512f541d54..b151aa4a97 100644 --- a/pkg/controller/clone/csi-clone_test.go +++ b/pkg/controller/clone/csi-clone_test.go @@ -155,6 +155,7 @@ var _ = Describe("CSIClonePhase test", func() { Expect(pvc.Spec.DataSourceRef.Namespace).To(BeNil()) Expect(pvc.Spec.DataSourceRef.Name).To(Equal(sourceClaim.Name)) Expect(pvc.Annotations[cc.AnnPopulatorKind]).To(Equal(cdiv1.VolumeCloneSourceRef)) + Expect(pvc.Annotations[cc.AnnExcludeFromVeleroBackup]).To(Equal("true")) Expect(pvc.Spec.Resources.Requests[corev1.ResourceStorage]). To(Equal(sourceClaim.Status.Capacity[corev1.ResourceStorage])) Expect(pvc.Labels[p.OwnershipLabel]).To(Equal("uid")) diff --git a/pkg/controller/clone/host-clone.go b/pkg/controller/clone/host-clone.go index f7f6d2506e..03a2cad98f 100644 --- a/pkg/controller/clone/host-clone.go +++ b/pkg/controller/clone/host-clone.go @@ -120,6 +120,7 @@ func (p *HostClonePhase) createClaim(ctx context.Context) (*corev1.PersistentVol cc.AddAnnotation(claim, cc.AnnPodRestarts, "0") cc.AddAnnotation(claim, cc.AnnCloneRequest, fmt.Sprintf("%s/%s", p.Namespace, p.SourceName)) cc.AddAnnotation(claim, cc.AnnPopulatorKind, cdiv1.VolumeCloneSourceRef) + cc.AddAnnotation(claim, cc.AnnExcludeFromVeleroBackup, "true") cc.AddAnnotation(claim, cc.AnnEventSourceKind, p.Owner.GetObjectKind().GroupVersionKind().Kind) cc.AddAnnotation(claim, cc.AnnEventSource, fmt.Sprintf("%s/%s", p.Owner.GetNamespace(), p.Owner.GetName())) if p.OwnershipLabel != "" { diff --git a/pkg/controller/clone/host-clone_test.go b/pkg/controller/clone/host-clone_test.go index 916f3d2d9c..60eb8f4c31 100644 --- a/pkg/controller/clone/host-clone_test.go +++ b/pkg/controller/clone/host-clone_test.go @@ -105,6 +105,7 @@ var _ = Describe("HostClonePhase test", func() { Expect(pvc.Annotations[cc.AnnPodRestarts]).To(Equal("0")) Expect(pvc.Annotations[cc.AnnCloneRequest]).To(Equal("ns/source")) Expect(pvc.Annotations[cc.AnnPopulatorKind]).To(Equal(cdiv1.VolumeCloneSourceRef)) + Expect(pvc.Annotations[cc.AnnExcludeFromVeleroBackup]).To(Equal("true")) Expect(pvc.Labels[p.OwnershipLabel]).To(Equal("uid")) Expect(pvc.Annotations[cc.AnnImmediateBinding]).To(Equal("")) _, ok := pvc.Annotations[cc.AnnPriorityClassName] diff --git a/pkg/controller/clone/snap-clone.go b/pkg/controller/clone/snap-clone.go index d34f9398b1..949a84fb8d 100644 --- a/pkg/controller/clone/snap-clone.go +++ b/pkg/controller/clone/snap-clone.go @@ -100,6 +100,7 @@ func (p *SnapshotClonePhase) createClaim(ctx context.Context, snapshot *snapshot } cc.AddAnnotation(claim, cc.AnnPopulatorKind, cdiv1.VolumeCloneSourceRef) + cc.AddAnnotation(claim, cc.AnnExcludeFromVeleroBackup, "true") if p.OwnershipLabel != "" { AddOwnershipLabel(p.OwnershipLabel, claim, p.Owner) } diff --git a/pkg/controller/clone/snap-clone_test.go b/pkg/controller/clone/snap-clone_test.go index 1f257f4ab1..269fbe9939 100644 --- a/pkg/controller/clone/snap-clone_test.go +++ b/pkg/controller/clone/snap-clone_test.go @@ -175,6 +175,7 @@ var _ = Describe("SnapshotClonePhase test", func() { Expect(pvc.Spec.DataSourceRef.Namespace).To(BeNil()) Expect(pvc.Spec.DataSourceRef.Name).To(Equal(sourceName)) Expect(pvc.Annotations[cc.AnnPopulatorKind]).To(Equal(cdiv1.VolumeCloneSourceRef)) + Expect(pvc.Annotations[cc.AnnExcludeFromVeleroBackup]).To(Equal("true")) Expect(pvc.Spec.Resources.Requests[corev1.ResourceStorage]).To(Equal(restoreSize)) Expect(pvc.Labels[p.OwnershipLabel]).To(Equal("uid")) }) diff --git a/pkg/controller/common/util.go b/pkg/controller/common/util.go index 3b71328628..c1464fd1ec 100644 --- a/pkg/controller/common/util.go +++ b/pkg/controller/common/util.go @@ -245,6 +245,9 @@ const ( // AnnImmediateBinding provides a const to indicate whether immediate binding should be performed on the PV (overrides global config) AnnImmediateBinding = AnnAPIGroup + "/storage.bind.immediate.requested" + //AnnExcludeFromVeleroBackup provides a const to indicate whether an object should be excluded from velero backup + AnnExcludeFromVeleroBackup = "velero.io/exclude-from-backup" + // AnnSelectedNode annotation is added to a PVC that has been triggered by scheduler to // be dynamically provisioned. Its value is the name of the selected node. AnnSelectedNode = "volume.kubernetes.io/selected-node" diff --git a/pkg/controller/populators/import-populator_test.go b/pkg/controller/populators/import-populator_test.go index d1af8892bb..b228072fc9 100644 --- a/pkg/controller/populators/import-populator_test.go +++ b/pkg/controller/populators/import-populator_test.go @@ -266,6 +266,7 @@ var _ = Describe("Import populator tests", func() { Expect(pvcPrime.GetAnnotations()[AnnImmediateBinding]).To(Equal("")) Expect(pvcPrime.GetAnnotations()[AnnUploadRequest]).To(Equal("")) Expect(pvcPrime.GetAnnotations()[AnnPopulatorKind]).To(Equal(cdiv1.VolumeImportSourceRef)) + Expect(pvcPrime.GetAnnotations()[AnnExcludeFromVeleroBackup]).To(Equal("true")) Expect(pvcPrime.GetAnnotations()[AnnPreallocationRequested]).To(Equal("true")) Expect(pvcPrime.GetAnnotations()[AnnEndpoint]).To(Equal("http://example.com/data")) Expect(pvcPrime.GetAnnotations()[AnnSource]).To(Equal(SourceHTTP)) diff --git a/pkg/controller/populators/populator-base.go b/pkg/controller/populators/populator-base.go index 562c327f75..d5590c1c7d 100644 --- a/pkg/controller/populators/populator-base.go +++ b/pkg/controller/populators/populator-base.go @@ -172,6 +172,7 @@ func (r *ReconcilerBase) createPVCPrime(pvc *corev1.PersistentVolumeClaim, sourc labels := make(map[string]string) labels[common.CDILabelKey] = common.CDILabelValue annotations := make(map[string]string) + annotations[cc.AnnExcludeFromVeleroBackup] = "true" annotations[cc.AnnImmediateBinding] = "" if waitForFirstConsumer { annotations[cc.AnnSelectedNode] = pvc.Annotations[cc.AnnSelectedNode] diff --git a/pkg/controller/populators/upload-populator_test.go b/pkg/controller/populators/upload-populator_test.go index 01a2f78a64..8843e7f4be 100644 --- a/pkg/controller/populators/upload-populator_test.go +++ b/pkg/controller/populators/upload-populator_test.go @@ -78,6 +78,7 @@ var _ = Describe("Datavolume controller reconcile loop", func() { Expect(pvcPrime.GetAnnotations()[cc.AnnContentType]).To(Equal(contentType)) Expect(pvcPrime.GetAnnotations()[cc.AnnPreallocationRequested]).To(Equal(strconv.FormatBool(preallocation))) Expect(pvcPrime.GetAnnotations()[cc.AnnPopulatorKind]).To(Equal(cdiv1.VolumeUploadSourceRef)) + Expect(pvcPrime.GetAnnotations()[cc.AnnExcludeFromVeleroBackup]).To(Equal("true")) _, err = r.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Name: "test-pvc", Namespace: metav1.NamespaceDefault}}) Expect(err).ToNot(HaveOccurred()) @@ -324,6 +325,7 @@ var _ = Describe("Datavolume controller reconcile loop", func() { Expect(pvcPrime.GetAnnotations()[cc.AnnImmediateBinding]).To(Equal("")) Expect(pvcPrime.GetAnnotations()[cc.AnnUploadRequest]).To(Equal("")) Expect(pvcPrime.GetAnnotations()[cc.AnnPopulatorKind]).To(Equal(cdiv1.VolumeUploadSourceRef)) + Expect(pvcPrime.GetAnnotations()[cc.AnnExcludeFromVeleroBackup]).To(Equal("true")) Expect(pvcPrime.Annotations[key]).To(Equal(expectedValue)) }, Entry("No extra annotations", "", "", ""),