diff --git a/changelogs/unreleased/4391-ywk253100 b/changelogs/unreleased/4391-ywk253100 new file mode 100644 index 0000000000..99a1ae5fac --- /dev/null +++ b/changelogs/unreleased/4391-ywk253100 @@ -0,0 +1 @@ +Keep the annotation "pv.kubernetes.io/provisioned-by" when restoring PVs \ No newline at end of file diff --git a/pkg/restore/restore.go b/pkg/restore/restore.go index 08b41bffc6..a4fd12a2e5 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -1569,10 +1569,6 @@ func resetVolumeBindingInfo(obj *unstructured.Unstructured) *unstructured.Unstru // the PV(C) controller to take the two objects and bind them again. delete(annotations, KubeAnnBoundByController) - // Remove the provisioned-by annotation which signals that the persistent - // volume was dynamically provisioned; it is now statically provisioned. - delete(annotations, KubeAnnDynamicallyProvisioned) - // GetAnnotations returns a copy, so we have to set them again. obj.SetAnnotations(annotations) diff --git a/pkg/restore/restore_test.go b/pkg/restore/restore_test.go index b0dea25f78..766e3b103b 100644 --- a/pkg/restore/restore_test.go +++ b/pkg/restore/restore_test.go @@ -2980,7 +2980,7 @@ func Test_resetVolumeBindingInfo(t *testing.T) { "resourceVersion": "1"}).Unstructured, expected: NewTestUnstructured().WithMetadataField("kind", "persistentVolume"). WithName("pv-1"). - WithAnnotations(). + WithAnnotations(KubeAnnDynamicallyProvisioned). WithSpecField("claimRef", map[string]interface{}{ "namespace": "ns-1", "name": "pvc-1"}).Unstructured, }, @@ -2990,7 +2990,6 @@ func Test_resetVolumeBindingInfo(t *testing.T) { WithName("pvc-1").WithAnnotations( KubeAnnBindCompleted, KubeAnnBoundByController, - KubeAnnDynamicallyProvisioned, ).WithSpecField("volumeName", "pv-1").Unstructured, expected: NewTestUnstructured().WithMetadataField("kind", "persistentVolumeClaim"). WithName("pvc-1").WithAnnotations().