mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
feat(resize): adding Online volume expansion support for ZFSPV
We can resize the volume by updating the PVC yaml to the desired size and apply it. The ZFS Driver will take care of updating the quota in case of dataset. If we are using a Zvol and have mounted it as ext4 or xfs filesystem, the driver will take care of expanding the volume via reize2fs/xfs_growfs binaries. For resize, storageclass that provisions the pvc must suppo rt resize. We should have allowVolumeExpansion as true in storageclass ```yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: openebs-zfspv allowVolumeExpansion: true parameters: poolname: "zfspv-pool" provisioner: zfs.csi.openebs.io ``` Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
dc5edb901c
commit
86e623a369
7 changed files with 278 additions and 3 deletions
|
|
@ -236,6 +236,27 @@ func buildVolumeSetArgs(vol *apis.ZFSVolume) []string {
|
|||
return ZFSVolArg
|
||||
}
|
||||
|
||||
// builldVolumeResizeArgs returns volume set for resizing the zfs volume
|
||||
func buildVolumeResizeArgs(vol *apis.ZFSVolume) []string {
|
||||
var ZFSVolArg []string
|
||||
|
||||
volume := vol.Spec.PoolName + "/" + vol.Name
|
||||
|
||||
ZFSVolArg = append(ZFSVolArg, ZFSSetArg)
|
||||
|
||||
if vol.Spec.VolumeType == VOLTYPE_DATASET {
|
||||
quotaProperty := "quota=" + vol.Spec.Capacity
|
||||
ZFSVolArg = append(ZFSVolArg, quotaProperty)
|
||||
} else {
|
||||
volsizeProperty := "volsize=" + vol.Spec.Capacity
|
||||
ZFSVolArg = append(ZFSVolArg, volsizeProperty)
|
||||
}
|
||||
|
||||
ZFSVolArg = append(ZFSVolArg, volume)
|
||||
|
||||
return ZFSVolArg
|
||||
}
|
||||
|
||||
// builldVolumeDestroyArgs returns volume destroy command along with attributes as a string array
|
||||
func buildVolumeDestroyArgs(vol *apis.ZFSVolume) []string {
|
||||
var ZFSVolArg []string
|
||||
|
|
@ -496,3 +517,21 @@ func GetVolumeDevPath(vol *apis.ZFSVolume) (string, error) {
|
|||
|
||||
return dev, nil
|
||||
}
|
||||
|
||||
func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string) error {
|
||||
|
||||
volume := vol.Spec.PoolName + "/" + vol.Name
|
||||
args := buildVolumeResizeArgs(vol)
|
||||
cmd := exec.Command(ZFSVolCmd, args...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
logrus.Errorf(
|
||||
"zfs: could not resize the volume %v cmd %v error: %s", volume, args, string(out),
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
err = handleVolResize(vol, mountpath)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue