From 287386ad9ff8aadbd0fe4d2cff9a0c7c4c045a0c Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Fri, 21 Aug 2020 11:59:55 +0800 Subject: [PATCH] optimize pvc resizer logic (#3145) (#3147) Signed-off-by: ti-srebot Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com> --- pkg/manager/member/pvc_resizer.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/manager/member/pvc_resizer.go b/pkg/manager/member/pvc_resizer.go index c8747d27183..598e76d8c41 100644 --- a/pkg/manager/member/pvc_resizer.go +++ b/pkg/manager/member/pvc_resizer.go @@ -162,11 +162,12 @@ func (p *pvcResizer) patchPVCs(ns string, selector labels.Selector, storageReque if err != nil { return err } - if !volumeExpansionSupported { - klog.Warningf("Storage Class %q used by PVC %s/%s does not support volume expansion, skipped", *pvc.Spec.StorageClassName, pvc.Namespace, pvc.Name) - continue - } + if currentRequest, ok := pvc.Spec.Resources.Requests[corev1.ResourceStorage]; !ok || storageRequest.Cmp(currentRequest) > 0 { + if !volumeExpansionSupported { + klog.Warningf("Storage Class %q used by PVC %s/%s does not support volume expansion, skipped", *pvc.Spec.StorageClassName, pvc.Namespace, pvc.Name) + continue + } _, err = p.kubeCli.CoreV1().PersistentVolumeClaims(pvc.Namespace).Patch(pvc.Name, types.MergePatchType, mergePatch) if err != nil { return err