Skip to content

Commit

Permalink
fix(expansion): add an error message to guide users in resolving the …
Browse files Browse the repository at this point in the history
…stuck volume expansion cancellation

Longhron 9466

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit committed Sep 16, 2024
1 parent b393140 commit 8173d64
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions manager/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,6 @@ func (m *VolumeManager) CancelExpansion(volumeName string) (v *longhorn.Volume,
if err != nil {
return nil, err
}
if !v.Status.ExpansionRequired {
return nil, fmt.Errorf("volume expansion is not started")
}
if v.Status.IsStandby {
return nil, fmt.Errorf("canceling expansion for standby volume is not supported")
}

var engine *longhorn.Engine
es, err := m.ds.ListVolumeEngines(v.Name)
Expand All @@ -574,6 +568,17 @@ func (m *VolumeManager) CancelExpansion(volumeName string) (v *longhorn.Volume,
engine = e
}

if !v.Status.ExpansionRequired {
if v.Spec.Size == engine.Spec.VolumeSize && v.Spec.Size != engine.Status.CurrentSize {
return nil, fmt.Errorf("volume has already been expanded to %v and cannot revert to size %v. Please manually expand it to %v to resolve the stuck cancellation",
engine.Status.CurrentSize, v.Spec.Size, engine.Status.CurrentSize)
}
return nil, fmt.Errorf("volume expansion is not started")
}
if v.Status.IsStandby {
return nil, fmt.Errorf("canceling expansion for standby volume is not supported")
}

if engine.Status.IsExpanding {
return nil, fmt.Errorf("the engine expansion is in progress")
}
Expand Down

0 comments on commit 8173d64

Please sign in to comment.