Add btrfs support to the automatic volume resizer

This commit is contained in:
Seb Patane 2021-02-24 02:57:37 +11:00 committed by Seb Patane
parent 6cacfe9e3a
commit 1bb8960997

View File

@ -56,6 +56,8 @@ func (resizefs *ResizeFs) Resize(devicePath string, deviceMountPath string) (boo
return resizefs.extResize(devicePath)
case "xfs":
return resizefs.xfsResize(deviceMountPath)
case "btrfs":
return resizefs.btrfsResize(deviceMountPath)
}
return false, fmt.Errorf("ResizeFS.Resize - resize of format %s is not supported for device %s mounted at %s", format, devicePath, deviceMountPath)
}
@ -84,3 +86,16 @@ func (resizefs *ResizeFs) xfsResize(deviceMountPath string) (bool, error) {
resizeError := fmt.Errorf("resize of device %s failed: %v. xfs_growfs output: %s", deviceMountPath, err, string(output))
return false, resizeError
}
func (resizefs *ResizeFs) btrfsResize(deviceMountPath string) (bool, error) {
args := []string{"filesystem", "resize", "max", deviceMountPath}
output, err := resizefs.exec.Command("btrfs", args...).CombinedOutput()
if err == nil {
klog.V(2).Infof("Device %s resized successfully", deviceMountPath)
return true, nil
}
resizeError := fmt.Errorf("resize of device %s failed: %v. btrfs output: %s", deviceMountPath, err, string(output))
return false, resizeError
}