未验证 提交 dab20a2e 编写于 作者: T Thomas Strömberg 提交者: GitHub

Merge pull request #9163 from tstromberg/driver-advice

docker: Improve overlay module check (behavior & UX)
......@@ -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 {
......
......@@ -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)
}
......
......@@ -19,6 +19,7 @@ package docker
import (
"context"
"fmt"
"os"
"os/exec"
"runtime"
"strings"
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册