Skip to content

Commit

Permalink
Detect device path for mount point
Browse files Browse the repository at this point in the history
  • Loading branch information
bertinatto committed Apr 5, 2019
1 parent 2257cf9 commit 827e09f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,21 @@ func (d *nodeService) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV
// TODO: range specified
}

r := resizefs.NewResizeFs(d.mounter)

// TODO: get the mount path that's required for XFS
_, err := r.Resize(req.GetVolumePath(), "" /* mount path for xfs */)
args := []string{"-o", "source", "--noheadings", "--target", req.GetVolumePath()}
output, err := d.mounter.Exec.Run("findmnt", args...)
if err != nil {
return nil, err
return nil, status.Errorf(codes.Internal, "Could not determine device path: %v", err)

}

devicePath := strings.TrimSpace(string(output))
if len(devicePath) == 0 {
return nil, status.Errorf(codes.Internal, "Could not get valid device for mount path: %q", req.GetVolumePath())
}

r := resizefs.NewResizeFs(d.mounter)
if _, err := r.Resize(devicePath, req.GetVolumePath()); err != nil {
return nil, status.Errorf(codes.Internal, "Could not resize volume %q: %v", volumeID, err)
}

return &csi.NodeExpandVolumeResponse{}, nil
Expand Down

0 comments on commit 827e09f

Please sign in to comment.