Skip to content

Commit

Permalink
incusd/storage/utils: Only show actual errors in growFileSystem
Browse files Browse the repository at this point in the history
This was masking an actual resize2fs error in our tests.

Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Sep 21, 2024
1 parent f26f6e7 commit 24542ac
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions internal/server/storage/drivers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,21 +514,20 @@ func growFileSystem(fsType string, devPath string, vol Volume) error {
}

return vol.MountTask(func(mountPath string, op *operations.Operation) error {
var msg string
var err error
switch fsType {
case "ext4":
msg, err = subprocess.TryRunCommand("resize2fs", devPath)
_, err = subprocess.TryRunCommand("resize2fs", devPath)
case "xfs":
msg, err = subprocess.TryRunCommand("xfs_growfs", mountPath)
_, err = subprocess.TryRunCommand("xfs_growfs", mountPath)
case "btrfs":
msg, err = subprocess.TryRunCommand("btrfs", "filesystem", "resize", "max", mountPath)
_, err = subprocess.TryRunCommand("btrfs", "filesystem", "resize", "max", mountPath)
default:
return fmt.Errorf("Unrecognised filesystem type %q", fsType)
}

if err != nil {
return fmt.Errorf("Could not grow underlying %q filesystem for %q: %s", fsType, devPath, msg)
return fmt.Errorf("Could not grow underlying %q filesystem for %q: %w", fsType, devPath, err)
}

return nil
Expand Down

0 comments on commit 24542ac

Please sign in to comment.