mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
feat(resize): adding resize support for raw block volumes
Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
8335440d4c
commit
88ad25ec9c
3 changed files with 25 additions and 3 deletions
1
changelogs/unreleased/281-pawanpraka1
Normal file
1
changelogs/unreleased/281-pawanpraka1
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
adding resize support for raw block volumes
|
||||||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package driver
|
package driver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
|
@ -330,7 +331,23 @@ func (ns *node) NodeExpandVolume(
|
||||||
err.Error(),
|
err.Error(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if err = zfs.ResizeZFSVolume(vol, req.GetVolumePath()); err != nil {
|
|
||||||
|
// find if it is block device so that we don't attempt filesystem resize
|
||||||
|
st, err := os.Stat(req.GetVolumePath())
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to stat mountpath %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
resizefs := false
|
||||||
|
|
||||||
|
// doing this dirty check as volume capabilities are not passed for NodeExpandVolume
|
||||||
|
// CSI 1.2 spec will probably solve this
|
||||||
|
if st.IsDir() {
|
||||||
|
// it is not a block device, resize the filesystem
|
||||||
|
resizefs = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = zfs.ResizeZFSVolume(vol, req.GetVolumePath(), resizefs); err != nil {
|
||||||
return nil, status.Errorf(
|
return nil, status.Errorf(
|
||||||
codes.Internal,
|
codes.Internal,
|
||||||
"failed to handle NodeExpandVolume Request for %s, {%s}",
|
"failed to handle NodeExpandVolume Request for %s, {%s}",
|
||||||
|
|
|
||||||
|
|
@ -703,7 +703,7 @@ func GetVolumeDevPath(vol *apis.ZFSVolume) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResizeZFSVolume resize volume
|
// ResizeZFSVolume resize volume
|
||||||
func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string) error {
|
func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string, resizefs bool) error {
|
||||||
|
|
||||||
volume := vol.Spec.PoolName + "/" + vol.Name
|
volume := vol.Spec.PoolName + "/" + vol.Name
|
||||||
args := buildVolumeResizeArgs(vol)
|
args := buildVolumeResizeArgs(vol)
|
||||||
|
|
@ -717,7 +717,11 @@ func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = handleVolResize(vol, mountpath)
|
if resizefs == true {
|
||||||
|
// resize the filesystem so that applications can use the expanded space
|
||||||
|
err = handleVolResize(vol, mountpath)
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue