Skip to content

Commit ccf4ef5

Browse files
committed
We need to ensure that we are not reading stale PV objects
So as we don't end up resizing same object more than once
1 parent d017b1f commit ccf4ef5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/controller/controller.go

+9
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@ func (ctrl *resizeController) pvNeedResize(pvc *v1.PersistentVolumeClaim, pv *v1
341341
return false
342342
}
343343

344+
// lets make sure that we are reading latest PV object so as any PV updates that might have happened
345+
// is available and we do not inadvertently call resize again on same PV.
346+
pv, err := ctrl.kubeClient.CoreV1().PersistentVolumes().Get(context.TODO(), pv.Name, metav1.GetOptions{})
347+
348+
if err != nil {
349+
klog.Errorf("error fetching PersistentVolume %q: %v", pv.Name, err)
350+
return false
351+
}
352+
344353
pvSize := pv.Spec.Capacity[v1.ResourceStorage]
345354
requestSize := pvc.Spec.Resources.Requests[v1.ResourceStorage]
346355
if pvSize.Cmp(requestSize) >= 0 {

0 commit comments

Comments
 (0)