Skip to content

Commit

Permalink
Keep the annotation "pv.kubernetes.io/provisioned-by" when restoring PVs
Browse files Browse the repository at this point in the history
More details please refer to vmware-tanzu#3470 (comment)

Fixes vmware-tanzu#3470

Signed-off-by: Wenkai Yin(尹文开) <[email protected]>
  • Loading branch information
ywk253100 committed Dec 21, 2021
1 parent d627362 commit 648f3ac
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/4391-ywk253100
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep the annotation "pv.kubernetes.io/provisioned-by" when restoring PVs
4 changes: 0 additions & 4 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions pkg/restore/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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().
Expand Down

0 comments on commit 648f3ac

Please sign in to comment.