diff --git a/pkg/minikube/exit/exit.go b/pkg/minikube/exit/exit.go index b15e319e9353..b0a575700faa 100644 --- a/pkg/minikube/exit/exit.go +++ b/pkg/minikube/exit/exit.go @@ -73,7 +73,6 @@ func WithError(msg string, err error) { // WithProblem outputs info related to a known problem and exits. func WithProblem(msg string, err error, p *problem.Problem) { out.ErrT(out.Empty, "") - glog.Errorf("%+v\n", p) out.FailureT("[{{.id}}] {{.msg}} {{.error}}", out.V{"msg": msg, "id": p.ID, "error": p.Err}) p.Display() if p.ShowIssueLink { diff --git a/pkg/minikube/machine/fix.go b/pkg/minikube/machine/fix.go index 2bd400fe2aaa..f36f254d851b 100644 --- a/pkg/minikube/machine/fix.go +++ b/pkg/minikube/machine/fix.go @@ -59,6 +59,7 @@ func fixHost(api libmachine.API, cc *config.ClusterConfig, n *config.Node) (*hos if err != nil { return h, errors.Wrap(err, "Error loading existing host. Please try running [minikube delete], then run [minikube start] again.") } + defer postStartValidations(h, cc.Driver) driverName := h.Driver.DriverName() diff --git a/pkg/minikube/machine/start.go b/pkg/minikube/machine/start.go index 6c3596365989..f36eca251d14 100644 --- a/pkg/minikube/machine/start.go +++ b/pkg/minikube/machine/start.go @@ -23,6 +23,8 @@ import ( "os/exec" "path" "path/filepath" + "strconv" + "strings" "time" "github.com/docker/machine/libmachine" @@ -37,6 +39,7 @@ import ( "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/driver" + "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/out/register" @@ -149,6 +152,7 @@ func createHost(api libmachine.API, cfg *config.ClusterConfig, n *config.Node) ( if err != nil { return nil, errors.Wrap(err, "new host") } + defer postStartValidations(h, cfg.Driver) h.HostOptions.AuthOptions.CertDir = localpath.MiniPath() h.HostOptions.AuthOptions.StorePath = localpath.MiniPath() @@ -202,6 +206,31 @@ func timedCreateHost(h *host.Host, api libmachine.API, t time.Duration) error { } } +// postStartValidations are validations against the host after it is created +// TODO: Add validations for VM drivers as well, see issue #9035 +func postStartValidations(h *host.Host, drvName string) { + if !driver.IsKIC(drvName) { + return + } + // make sure /var isn't full, otherwise warn + output, err := h.RunSSHCommand("df -h /var | awk 'NR==2{print $5}'") + if err != nil { + glog.Warningf("error running df -h /var: %v", err) + } + output = strings.Trim(output, "\n") + percentageFull, err := strconv.Atoi(output[:len(output)-1]) + if err != nil { + glog.Warningf("error getting percentage of /var that is free: %v", err) + } + if percentageFull >= 99 { + exit.WithError("", fmt.Errorf("docker daemon out of memory. No space left on device")) + } + + if percentageFull > 80 { + out.WarningT("The docker daemon is almost out of memory, run 'docker system prune' to free up space") + } +} + // postStart are functions shared between startHost and fixHost func postStartSetup(h *host.Host, mc config.ClusterConfig) error { glog.Infof("post-start starting for %q (driver=%q)", h.Name, h.DriverName) diff --git a/pkg/minikube/problem/err_map.go b/pkg/minikube/problem/err_map.go index 058dee90eb7b..4dec02bd31b9 100644 --- a/pkg/minikube/problem/err_map.go +++ b/pkg/minikube/problem/err_map.go @@ -578,3 +578,18 @@ var stateProblems = map[string]match{ Issues: []int{7256}, }, } + +// dockerProblems are issues relating to issues with the docker driver +var dockerProblems = map[string]match{ + "NO_SPACE_ON_DEVICE": { + Regexp: re(`.*docker.*No space left on device.*`), + Advice: `Try at least one of the following to free up space on the device: + + 1. Run "docker system prune" to remove unused docker data + 2. Increase the amount of memory allocated to Docker for Desktop via + Docker icon > Preferences > Resources > Disk Image Size + 3. Run "minikube ssh -- docker system prune" if using the docker container runtime +`, + Issues: []int{9024}, + }, +} diff --git a/pkg/minikube/problem/problem.go b/pkg/minikube/problem/problem.go index ae7b62eb8e58..e859eaf534aa 100644 --- a/pkg/minikube/problem/problem.go +++ b/pkg/minikube/problem/problem.go @@ -104,6 +104,7 @@ func FromError(err error, goos string) *Problem { netProblems, deployProblems, stateProblems, + dockerProblems, } var osMatch *Problem