Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep the annotation "pv.kubernetes.io/provisioned-by" when restoring PVs #232

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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)

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 @@ -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,
},
Expand All @@ -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().
Expand Down