Merge pull request #4391 from ywk253100/211123_anno

Keep the annotation "pv.kubernetes.io/provisioned-by" when restoring PVs
This commit is contained in:
Daniel Jiang
2021-12-21 11:08:25 +08:00
committed by GitHub
3 changed files with 2 additions and 6 deletions

View File

@@ -0,0 +1 @@
Keep the annotation "pv.kubernetes.io/provisioned-by" when restoring PVs

View File

@@ -1563,10 +1563,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)

View File

@@ -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().