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:
Pawan 2020-03-02 12:03:03 +05:30 committed by Kiran Mova
parent dc5edb901c
commit 86e623a369
7 changed files with 278 additions and 3 deletions

View file

@ -17,6 +17,7 @@ package zfs
import (
"github.com/Sirupsen/logrus"
"os"
"strconv"
apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/core/v1alpha1"
"github.com/openebs/zfs-localpv/pkg/builder/snapbuilder"
@ -85,6 +86,15 @@ func ProvisionVolume(
return err
}
// ResizeVolume resizes the zfs volume
func ResizeVolume(vol *apis.ZFSVolume, newSize int64) error {
vol.Spec.Capacity = strconv.FormatInt(int64(newSize), 10)
_, err := volbuilder.NewKubeclient().WithNamespace(OpenEBSNamespace).Update(vol)
return err
}
// ProvisionSnapshot creates a ZFSSnapshot CR,
// watcher for zvc is present in CSI agent
func ProvisionSnapshot(