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

[Fix]: Skip fuse check when kernel is WSL2 #319

Open
wants to merge 1 commit into
base: tombstone
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions internal/task/step/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"os"
"strings"

comm "github.com/opencurve/curveadm/internal/common"
"github.com/opencurve/curveadm/internal/errno"
"github.com/opencurve/curveadm/internal/task/context"
"github.com/opencurve/curveadm/internal/utils"
Expand Down Expand Up @@ -475,6 +476,15 @@ func (s *UnixName) Execute(ctx *context.Context) error {
}

func (s *ModInfo) Execute(ctx *context.Context) error {
isWsl2, err := ctx.Module().Shell().IsWsl2()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate step is better?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't get it.

if err == nil && isWsl2 {
// NOTE: FUSE is statically compiled into the WSL2 kernel
// See also: https://github.com/microsoft/WSL/issues/17#issuecomment-759817472
if s.Name == comm.KERNERL_MODULE_FUSE {
*s.Success = true
return nil
}
}
cmd := ctx.Module().Shell().ModInfo(s.Name)
out, err := cmd.Execute(s.ExecOptions)
return PostHandle(s.Success, s.Out, out, err, errno.ERR_GET_KERNEL_MODULE_INFO_FAILED)
Expand Down
12 changes: 12 additions & 0 deletions pkg/module/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ func (s *Shell) Execute(options ExecOptions) (string, error) {
return execCommand(s.sshClient, s.tmpl, s.data, options)
}

func (s *Shell) IsWsl2() (isWsl2 bool, err error) {
cmd := s.Command("uname -a | grep \"WSL2\" | wc -l")
out, err := cmd.Execute(ExecOptions{})
if err != nil {
return
}
if out != "" && out[0] == '1' {
isWsl2 = true
}
return
}

// text
func (s *Shell) Sed(file ...string) *Shell {
s.tmpl = template.Must(template.New("sed").Parse(TEMPLATE_SED))
Expand Down