@@ -17,6 +17,7 @@ limitations under the License.
1717package modifycontroller
1818
1919import (
20+ "context"
2021 "fmt"
2122 "maps"
2223 "slices"
@@ -73,6 +74,7 @@ func (ctrl *modifyController) modify(pvc *v1.PersistentVolumeClaim, pv *v1.Persi
7374 return pvc , pv , err , false
7475 }
7576
77+ ctx := context .TODO ()
7678 inUncertainState := false
7779 if inProgress {
7880 _ , inUncertainState = ctrl .uncertainPVCs .Load (pvcKey )
@@ -89,10 +91,10 @@ func (ctrl *modifyController) modify(pvc *v1.PersistentVolumeClaim, pv *v1.Persi
8991 if err != nil {
9092 return pvc , pv , err , false
9193 }
92- return ctrl .controllerModifyVolumeWithTarget (pvc , pv , vac )
94+ return ctrl .controllerModifyVolumeWithTarget (ctx , pvc , pv , vac )
9395 }
9496
95- return ctrl .validateVACAndModifyVolumeWithTarget (pvc , pv )
97+ return ctrl .validateVACAndModifyVolumeWithTarget (ctx , pvc , pv )
9698}
9799
98100func (ctrl * modifyController ) rolledBack (pvc * v1.PersistentVolumeClaim ) (* v1.PersistentVolumeClaim , error ) {
@@ -123,6 +125,7 @@ func (ctrl *modifyController) getTargetVAC(pvc *v1.PersistentVolumeClaim, vacNam
123125// func validateVACAndModifyVolumeWithTarget validate the VAC. The function sets pvc.Status.ModifyVolumeStatus
124126// to Pending if VAC does not exist and proceeds to trigger ModifyVolume if VAC exists
125127func (ctrl * modifyController ) validateVACAndModifyVolumeWithTarget (
128+ ctx context.Context ,
126129 pvc * v1.PersistentVolumeClaim ,
127130 pv * v1.PersistentVolume ) (* v1.PersistentVolumeClaim , * v1.PersistentVolume , error , bool ) {
128131
@@ -141,18 +144,19 @@ func (ctrl *modifyController) validateVACAndModifyVolumeWithTarget(
141144 // Record an event to indicate that external resizer is modifying this volume.
142145 ctrl .eventRecorder .Event (pvc , v1 .EventTypeNormal , util .VolumeModify ,
143146 fmt .Sprintf ("external resizer is modifying volume %s with vac %s" , pvc .Name , vac .Name ))
144- return ctrl .controllerModifyVolumeWithTarget (pvc , pv , vac )
147+ return ctrl .controllerModifyVolumeWithTarget (ctx , pvc , pv , vac )
145148}
146149
147150// func controllerModifyVolumeWithTarget trigger the CSI ControllerModifyVolume API call
148151// and handle both success and error scenarios
149152func (ctrl * modifyController ) controllerModifyVolumeWithTarget (
153+ ctx context.Context ,
150154 pvc * v1.PersistentVolumeClaim ,
151155 pv * v1.PersistentVolume ,
152156 vacObj * storagev1.VolumeAttributesClass ,
153157) (* v1.PersistentVolumeClaim , * v1.PersistentVolume , error , bool ) {
154158 var err error
155- pvc , pv , err = ctrl .callModifyVolumeOnPlugin (pvc , pv , vacObj )
159+ pvc , pv , err = ctrl .callModifyVolumeOnPlugin (ctx , pvc , pv , vacObj )
156160 if err == nil {
157161 klog .V (4 ).Infof ("Update volumeAttributesClass of PV %q to %s succeeded" , pv .Name , vacObj .Name )
158162 // Record an event to indicate that modify operation is successful.
@@ -195,6 +199,7 @@ func (ctrl *modifyController) controllerModifyVolumeWithTarget(
195199}
196200
197201func (ctrl * modifyController ) callModifyVolumeOnPlugin (
202+ ctx context.Context ,
198203 pvc * v1.PersistentVolumeClaim ,
199204 pv * v1.PersistentVolume ,
200205 vac * storagev1.VolumeAttributesClass ) (* v1.PersistentVolumeClaim , * v1.PersistentVolume , error ) {
@@ -209,7 +214,7 @@ func (ctrl *modifyController) callModifyVolumeOnPlugin(
209214 parameters [pvcNamespaceKey ] = pvc .GetNamespace ()
210215 parameters [pvNameKey ] = pv .GetName ()
211216 }
212- err := ctrl .modifier .Modify (pv , parameters )
217+ err := ctrl .modifier .Modify (ctx , pv , parameters )
213218
214219 if err != nil {
215220 return pvc , pv , err
0 commit comments