提交 1101f543 编写于 作者: M Medya Gh

add check for mod prob

上级 f52a682a
......@@ -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 checkOverlayMod()
}
glog.Warningf("docker returned error: %v", err)
......@@ -114,7 +114,22 @@ 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
// checkOverlayMod checks if overlay mod is installed on a system
func checkOverlayMod() registry.State {
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, "mod", "probe", "overlay")
_, err := cmd.Output()
if err != nil {
// try a different way
cmd := exec.CommandContext(ctx, "mod", "probe", "overlay")
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/"}
}
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/"}
......
......@@ -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
RoomForImprovement bool
Error error
Fix string
Doc string
}
// DriverDef defines how to initialize and load a machine driver
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册