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 driver on linux: warn if overlay module is not enabled #8541

Merged
merged 2 commits into from
Jun 25, 2020
Merged
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
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})
Copy link
Collaborator

Choose a reason for hiding this comment

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

{{.driver}} driver reported an issue that could affect performance

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")
medyagh marked this conversation as resolved.
Show resolved Hide resolved
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