Skip to content

Commit

Permalink
Merge pull request #8541 from medyagh/modprob_overlay
Browse files Browse the repository at this point in the history
docker driver on linux: Give warning if overlay module is not enabled
  • Loading branch information
medyagh authored Jun 25, 2020
2 parents 72e13c1 + 0121b44 commit 0b53e90
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
7 changes: 7 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,13 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
st := ds.State
glog.Infof("status for %s: %+v", name, st)

if st.NeedsImprovement { // warn but don't exit
out.ErrLn("")
out.WarningT("'{{.driver}}' driver reported a issue that could affect the performance.", out.V{"driver": name})
out.ErrT(out.Tip, "Suggestion: {{.fix}}", out.V{"fix": translate.T(st.Fix)})
out.ErrLn("")
}

if st.Error != nil {
out.ErrLn("")

Expand Down
46 changes: 44 additions & 2 deletions pkg/minikube/registry/drvs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func status() registry.State {
}
if err == nil {
glog.Infof("docker version: %s", output)
return registry.State{Installed: true, Healthy: true}
return checkNeedsImprovement()
}

glog.Warningf("docker returned error: %v", err)
Expand All @@ -114,7 +114,49 @@ func status() registry.State {
return registry.State{Error: err, Installed: true, Healthy: false, Doc: docURL}
}

//suggestFix matches a stderr with possible fix for the docker driver
// checkNeedsImprovement if overlay mod is installed on a system
func checkNeedsImprovement() registry.State {
if runtime.GOOS == "linux" {
return checkOverlayMod()
} // TODO #8540: on non-linux check if docker desktop has enough CPU/memory
return registry.State{Installed: true, Healthy: true}
}

// checkOverlayMod checks if
func checkOverlayMod() registry.State {
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, "modprobe", "overlay")
_, err := cmd.Output()
if err != nil {
// try a different way
cmd = exec.CommandContext(ctx, "uname", "-r")
out, err := cmd.Output()
if ctx.Err() == context.DeadlineExceeded {
glog.Warningf("%q timed out checking for ", strings.Join(cmd.Args, " "))
return registry.State{NeedsImprovement: true, Installed: true, Healthy: true, Fix: "enable overlayfs kernel module on your Linux"}
}
if err != nil {
glog.Warningf("couldn't verify the linux distro's uname : %s", err)
return registry.State{NeedsImprovement: true, Installed: true, Healthy: true, Fix: "enable overlayfs kernel module on your Linux"}
}
path := fmt.Sprintf("/lib/modules/%s/modules.builtin", string(out))
cmd = exec.CommandContext(ctx, "cat", path)
out, err = cmd.Output()
if err != nil {
glog.Warningf("overlay module was not found in %q", path)
return registry.State{NeedsImprovement: true, Installed: true, Healthy: true, Fix: "enable overlayfs kernel module on your Linux"}
}
if strings.Contains(string(out), "overlay") { // success
return registry.State{NeedsImprovement: false, Installed: true, Healthy: true}
}
glog.Warningf("overlay module was not found")
return registry.State{NeedsImprovement: true, Installed: true, Healthy: true}
}
return registry.State{Installed: true, Healthy: true}
}

// suggestFix matches a stderr with possible fix for the docker driver
func suggestFix(stderr string, err error) registry.State {
if strings.Contains(stderr, "permission denied") && runtime.GOOS == "linux" {
return registry.State{Error: err, Installed: true, Healthy: false, Fix: "Add your user to the 'docker' group: 'sudo usermod -aG docker $USER && newgrp docker'", Doc: "https://docs.docker.com/engine/install/linux-postinstall/"}
Expand Down
11 changes: 6 additions & 5 deletions pkg/minikube/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ type StatusChecker func() State

// State is the current state of the driver and its dependencies
type State struct {
Installed bool
Healthy bool
Error error
Fix string
Doc string
Installed bool
Healthy bool
NeedsImprovement bool // driver is healthy but could be improved
Error error
Fix string
Doc string
}

// DriverDef defines how to initialize and load a machine driver
Expand Down

0 comments on commit 0b53e90

Please sign in to comment.