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

docker: Improve overlay module check (behavior & UX) #9163

Merged
merged 8 commits into from
Sep 2, 2020
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