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 19e5002693..09f5e662a2 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -1562,10 +1562,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 faada13f9c..52c8e6986c 100644 --- a/pkg/restore/restore_test.go +++ b/pkg/restore/restore_test.go @@ -2997,7 +2997,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, }, @@ -3007,7 +3007,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().