Skip to content

Commit

Permalink
Merge pull request #9163 from tstromberg/driver-advice
Browse files Browse the repository at this point in the history
docker: Improve overlay module check (behavior & UX)
  • Loading branch information
tstromberg authored Sep 2, 2020
2 parents 914f10b + 1fdf163 commit dab20a2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
6 changes: 1 addition & 5 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,7 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
glog.Infof("status for %s: %+v", name, st)

if st.NeedsImprovement {
out.WarnReason(reason.Kind{
ID: fmt.Sprintf("PROVIDER_%s_IMPROVEMENT", strings.ToUpper(name)),
Advice: translate.T(st.Fix),
Style: style.Improvement,
}, `The '{{.driver}}' driver reported a performance issue`, out.V{"driver": name})
out.T(style.Improvement, `For improved {{.driver}} performance, {{.fix}}`, out.V{"driver": driver.FullName(ds.Name), "fix": translate.T(st.Fix)})
}

if st.Error == nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ func FullName(name string) string {
switch name {
case oci.Docker:
if IsDockerDesktop(name) {
return "Docker for Desktop"
return "Docker Desktop"
}
return "Docker Service"
return "Docker"
default:
return strings.Title(name)
}
Expand Down
43 changes: 13 additions & 30 deletions pkg/minikube/registry/drvs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package docker
import (
"context"
"fmt"
"os"
"os/exec"
"runtime"
"strings"
Expand Down Expand Up @@ -119,42 +120,24 @@ func status() registry.State {
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}
if _, err := os.Stat("/sys/module/overlay"); err == nil {
glog.Info("overlay module found")
return registry.State{Installed: true, Healthy: true}
}
return registry.State{Installed: true, Healthy: true}

if _, err := os.Stat("/sys/module/overlay2"); err == nil {
glog.Info("overlay2 module found")
return registry.State{Installed: true, Healthy: true}
}

glog.Warningf("overlay modules were not found")
return registry.State{NeedsImprovement: true, Installed: true, Healthy: true, Fix: "enable the overlay Linux kernel module using 'modprobe overlay'"}
}

// suggestFix matches a stderr with possible fix for the docker driver
Expand Down

0 comments on commit dab20a2

Please sign in to comment.