diff --git a/manager/volume.go b/manager/volume.go index 5ae12601ac..49d4dc1c59 100644 --- a/manager/volume.go +++ b/manager/volume.go @@ -468,6 +468,15 @@ func (m *VolumeManager) Expand(volumeName string, size int64) (v *longhorn.Volum size = util.RoundUpSize(size) + if v.Spec.Size >= size { + logrus.Infof("Volume %v expansion is not allowable since current size %v >= %v", v.Name, v.Spec.Size, size) + return v, nil + } + + if _, err := m.scheduler.CheckReplicasSizeExpansion(v, v.Spec.Size, size); err != nil { + return nil, err + } + kubernetesStatus := &v.Status.KubernetesStatus if kubernetesStatus.PVCName != "" && kubernetesStatus.LastPVCRefAt == "" { waitForPVCExpansion, size, err := m.checkAndExpandPVC(kubernetesStatus.Namespace, kubernetesStatus.PVCName, size) @@ -483,15 +492,6 @@ func (m *VolumeManager) Expand(volumeName string, size int64) (v *longhorn.Volum logrus.Infof("CSI plugin call to expand volume %v to size %v", v.Name, size) } - if v.Spec.Size >= size { - logrus.Infof("Volume %v expansion is not necessary since current size %v >= %v", v.Name, v.Spec.Size, size) - return v, nil - } - - if _, err := m.scheduler.CheckReplicasSizeExpansion(v, v.Spec.Size, size); err != nil { - return nil, err - } - previousSize := v.Spec.Size v.Spec.Size = size