Browse code

UPSTREAM: 24924: fix PrepareForUpdate bug for PV and PVC

Jordan Liggitt authored on 2016/04/28 20:13:02
Showing 2 changed files
... ...
@@ -64,7 +64,7 @@ func (persistentvolumeStrategy) AllowCreateOnUpdate() bool {
64 64
 // PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV
65 65
 func (persistentvolumeStrategy) PrepareForUpdate(obj, old runtime.Object) {
66 66
 	newPv := obj.(*api.PersistentVolume)
67
-	oldPv := obj.(*api.PersistentVolume)
67
+	oldPv := old.(*api.PersistentVolume)
68 68
 	newPv.Status = oldPv.Status
69 69
 }
70 70
 
... ...
@@ -86,7 +86,7 @@ var StatusStrategy = persistentvolumeStatusStrategy{Strategy}
86 86
 // PrepareForUpdate sets the Spec field which is not allowed to be changed when updating a PV's Status
87 87
 func (persistentvolumeStatusStrategy) PrepareForUpdate(obj, old runtime.Object) {
88 88
 	newPv := obj.(*api.PersistentVolume)
89
-	oldPv := obj.(*api.PersistentVolume)
89
+	oldPv := old.(*api.PersistentVolume)
90 90
 	newPv.Spec = oldPv.Spec
91 91
 }
92 92
 
... ...
@@ -64,7 +64,7 @@ func (persistentvolumeclaimStrategy) AllowCreateOnUpdate() bool {
64 64
 // PrepareForUpdate sets the Status field which is not allowed to be set by end users on update
65 65
 func (persistentvolumeclaimStrategy) PrepareForUpdate(obj, old runtime.Object) {
66 66
 	newPvc := obj.(*api.PersistentVolumeClaim)
67
-	oldPvc := obj.(*api.PersistentVolumeClaim)
67
+	oldPvc := old.(*api.PersistentVolumeClaim)
68 68
 	newPvc.Status = oldPvc.Status
69 69
 }
70 70
 
... ...
@@ -86,7 +86,7 @@ var StatusStrategy = persistentvolumeclaimStatusStrategy{Strategy}
86 86
 // PrepareForUpdate sets the Spec field which is not allowed to be changed when updating a PV's Status
87 87
 func (persistentvolumeclaimStatusStrategy) PrepareForUpdate(obj, old runtime.Object) {
88 88
 	newPv := obj.(*api.PersistentVolumeClaim)
89
-	oldPv := obj.(*api.PersistentVolumeClaim)
89
+	oldPv := old.(*api.PersistentVolumeClaim)
90 90
 	newPv.Spec = oldPv.Spec
91 91
 }
92 92