@@ -94,24 +94,23 @@ func (ctrl *modifyController) updateConditionBasedOnError(pvc *v1.PersistentVolu
9494// markControllerModifyVolumeStatus will mark ModifyVolumeStatus as completed in the PVC
9595// and update CurrentVolumeAttributesClassName, clear the conditions
9696func (ctrl * modifyController ) markControllerModifyVolumeCompleted (pvc * v1.PersistentVolumeClaim , pv * v1.PersistentVolume ) (* v1.PersistentVolumeClaim , * v1.PersistentVolume , error ) {
97+ modifiedVacName := pvc .Status .ModifyVolumeStatus .TargetVolumeAttributesClassName
98+
9799 // Update PVC
98100 newPVC := pvc .DeepCopy ()
101+
99102 // Update ModifyVolumeStatus to completed
100- var controllerModifyVolumeCompleted v1.PersistentVolumeClaimModifyVolumeStatus
101- if newPVC .Status .ModifyVolumeStatus == nil {
102- newPVC .Status .ModifyVolumeStatus = & v1.ModifyVolumeStatus {}
103- }
104- newPVC .Status .ModifyVolumeStatus .Status = controllerModifyVolumeCompleted
103+ newPVC .Status .ModifyVolumeStatus = nil
105104
106105 // Update CurrentVolumeAttributesClassName
107- newPVC .Status .CurrentVolumeAttributesClassName = & newPVC . Status . ModifyVolumeStatus . TargetVolumeAttributesClassName
106+ newPVC .Status .CurrentVolumeAttributesClassName = & modifiedVacName
108107
109- // Clear all the conditions
108+ // Clear all the conditions related to modify volume
110109 newPVC .Status .Conditions = clearModifyVolumeConditions (newPVC .Status .Conditions )
111110
112111 // Update PV
113112 newPV := pv .DeepCopy ()
114- newPV .Spec .VolumeAttributesClassName = & newPVC . Status . ModifyVolumeStatus . TargetVolumeAttributesClassName
113+ newPV .Spec .VolumeAttributesClassName = & modifiedVacName
115114
116115 // Update PV before PVC to avoid PV not getting updated but PVC did
117116 updatedPV , err := util .PatchPersistentVolume (ctrl .kubeClient , pv , newPV )
0 commit comments