Skip to content

Commit

Permalink
lxd/storage/drivers/powerflex: Always wait for volume resizes
Browse files Browse the repository at this point in the history
Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Jan 30, 2025
1 parent f89dc00 commit 7458ef7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lxd/storage/drivers/driver_powerflex_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/canonical/lxd/lxd/instancewriter"
"github.com/canonical/lxd/lxd/migration"
"github.com/canonical/lxd/lxd/operations"
"github.com/canonical/lxd/lxd/storage/connectors"
"github.com/canonical/lxd/lxd/storage/filesystem"
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/api"
Expand Down Expand Up @@ -604,6 +605,15 @@ func (d *powerflex) SetVolumeQuota(vol Volume, size string, allowUnsafeResize bo

defer cleanup()

// Always wait for the disk to reflect the new size.
// In case SetVolumeQuota is called on an already mapped volume,
// it might take some time until the actual size of the device is reflected on the host.
// This is for example the case when creating a volume and the filler performs a resize in case the image exceeds the volume's size.
err = connectors.WaitDiskDeviceResize(d.state.ShutdownCtx, devPath, sizeBytes)
if err != nil {
return fmt.Errorf("Failed waiting for volume %q to change its size: %w", vol.name, err)
}

// Grow the filesystem to fill block device.
err = growFileSystem(fsType, devPath, vol)
if err != nil {
Expand Down Expand Up @@ -633,6 +643,11 @@ func (d *powerflex) SetVolumeQuota(vol Volume, size string, allowUnsafeResize bo

defer cleanup()

err = connectors.WaitDiskDeviceResize(d.state.ShutdownCtx, devPath, sizeBytes)
if err != nil {
return fmt.Errorf("Failed waiting for volume %q to change its size: %w", vol.name, err)
}

// Move the VM GPT alt header to end of disk if needed (not needed in unsafe resize mode as it is
// expected the caller will do all necessary post resize actions themselves).
if vol.IsVMBlock() && !allowUnsafeResize {
Expand Down

0 comments on commit 7458ef7

Please sign in to comment.