Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(resize): adding resize support for raw block volumes #281

Merged
merged 1 commit into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/281-pawanpraka1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
adding resize support for raw block volumes
19 changes: 18 additions & 1 deletion pkg/driver/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package driver

import (
"os"
"strings"
"sync"

Expand Down Expand Up @@ -330,7 +331,23 @@ func (ns *node) NodeExpandVolume(
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(
codes.Internal,
"failed to handle NodeExpandVolume Request for %s, {%s}",
Expand Down
8 changes: 6 additions & 2 deletions pkg/zfs/zfs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ func GetVolumeDevPath(vol *apis.ZFSVolume) (string, error) {
}

// 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
args := buildVolumeResizeArgs(vol)
Expand All @@ -717,7 +717,11 @@ func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string) error {
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
}

Expand Down