diff --git a/pkg/controller/common/storage/storage-pvc.go b/pkg/controller/common/storage/storage-pvc.go index e7a59d19f..acdbb8d3b 100644 --- a/pkg/controller/common/storage/storage-pvc.go +++ b/pkg/controller/common/storage/storage-pvc.go @@ -49,7 +49,7 @@ func (c *PVC) UpdateOrCreate(ctx context.Context, pvc *core.PersistentVolumeClai return nil, fmt.Errorf("task is done") } - _, err := c.Get(ctx, pvc.Namespace, pvc.Name) + oldPvc, err := c.Get(ctx, pvc.Namespace, pvc.Name) if err != nil { if apiErrors.IsNotFound(err) { log.V(1).M(pvc).F().Error("PVC not found, need to create %s", util.NamespacedName(pvc)) @@ -62,6 +62,14 @@ func (c *PVC) UpdateOrCreate(ctx context.Context, pvc *core.PersistentVolumeClai // In case of any non-NotFound API error - unable to proceed log.V(1).M(pvc).F().Error("ERROR unable to get PVC(%s) err: %v", util.NamespacedName(pvc), err) return nil, err + } + + oldStorageRequest := oldPvc.Spec.Resources.Requests[core.ResourceStorage] + newStorageRequest := pvc.Spec.Resources.Requests[core.ResourceStorage] + + if oldStorageRequest.Cmp(newStorageRequest) == 1 { + log.V(1).M(pvc).F().Info("PVC storage was increased externally to greater value and value cannot be decreased, using greater value") + pvc.Spec.Resources.Requests[core.ResourceStorage] = oldStorageRequest } pvcUpdated, err := c.Update(ctx, pvc)