Merge pull request #99361 from Novex/btrfs-volume-resize

Add btrfs support to the automatic volume resizer
This commit is contained in:
Kubernetes Prow Robot 2021-03-02 01:23:19 -08:00 committed by GitHub
commit 930bede46e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}