Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failed to cancel volume expansion after engine is already expanded successfully #3165

Closed
wants to merge 1 commit into from

Conversation

derekbit
Copy link
Member

Which issue(s) this PR fixes:

Issue longhorn/longhorn#9466

What this PR does / why we need it:

When the volume has already been successfully expanded, if the cancellation is issued after completing the volume expansion, and the spec.size and status.currentSize of the volume and engine are as follows:

  • v.spec.size: 21474836480
  • e.spec.size: 21474836480
  • e.status.currentSize: 22548578304

The check

if e.Spec.VolumeSize == v.Spec.Size {
    return nil
}

prevents v.Status.ExpansionRequired from becoming true, which hinders the cancellation of the expansion.

Special notes for your reviewer:

Additional documentation or context

…ed successfully

When the volume has already been successfully expanded, if the cancellation is issued after
completing the volume expansion, and the spec.size and status.currentSize of the volume and
engine are as follows:

- v.spec.size: 21474836480
- e.spec.size: 21474836480
- e.status.currentSize: 22548578304

The check
```
if e.Spec.VolumeSize == v.Spec.Size {
    return nil
}
```

prevents v.Status.ExpansionRequired from becoming true, which hinders the cancellation
of the expansion.

Longhorn 9466

Signed-off-by: Derek Su <derek.su@suse.com>
@derekbit derekbit changed the title fix: allow cancellation of volume expansion when e.Status.CurrentSize is not equal to v.Spec.Size and e.Spec.VolumeSize fix: failed to cancel volume expansion after engine is already expanded successfully Sep 16, 2024
@@ -2026,7 +2026,7 @@ func (c *VolumeController) reconcileVolumeSize(v *longhorn.Volume, e *longhorn.E
if e == nil || rs == nil {
return nil
}
if e.Spec.VolumeSize == v.Spec.Size {
if e.Spec.VolumeSize == v.Spec.Size && e.Status.CurrentSize == v.Spec.Size {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix looks ok to me as far as resolving the issue. It seems this fix will allow v.Status.ExpansionRequired == true to be set again, which enables the user to cancel expansion, correcting the volume size to the post-expansion size v.Spec.Size = engine.Status.CurrentSize.

However, I am a bit confused about how v.Status.ExpansionRequired ended up being set to False during cancellation, as described in the issue.

Expanding volume through UI and then Cancelling expansion through UI results in volume stuck in expansion error:

IIRC, we only set v.Status.ExpansionRequired = False when e.Status.CurrentSize == v.Spec.Size.

But from the longhorn/longhorn#9466 (comment), there seems to be an inconsistency between the sizes in spec and status:

  • v.spec.size: 21474836480
  • e.spec.size: 21474836480
  • e.status.currentSize: 22548578304

Copy link
Member Author

@derekbit derekbit Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While expanding the volume and before cancelling the expansion, ExpansionRequired is true and the sizes are:

  • v.spec.size: 22548578304
  • e.spec.size: 22548578304
  • e.status.currentSize: 21474836480

After issuing the cancellation, v.spec.size and e.spec.size revert to 21474836480, and ExpansionRequired becomes false. Subsequently, the engine controller updates e.status.currentSize to the latest engine size of 22548578304. Therefore, the sizes become:

  • v.spec.size: 21474836480
  • e.spec.size: 21474836480
  • e.status.currentSize: 22548578304

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so this means the cancel volume expansion is ineffective once engineClientProxy.VolumeExpand() is invoked.

@derekbit
Copy link
Member Author

After discussing with @c3y1huang, the solution is unable to cancel the expansion. Need to figure out the new method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants