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

Warn if /var disk space is full and add a solution message #9028

Merged
merged 7 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 0 additions & 1 deletion pkg/minikube/exit/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/machine/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
28 changes: 28 additions & 0 deletions pkg/minikube/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"os/exec"
"path"
"path/filepath"
"strconv"
"strings"
"time"

"github.com/docker/machine/libmachine"
Expand All @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -202,6 +206,30 @@ func timedCreateHost(h *host.Host, api libmachine.API, t time.Duration) error {
}
}

// postStartValidations are validations against the host after it is created
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 {
priyawadhwa marked this conversation as resolved.
Show resolved Hide resolved
exit.WithError("", fmt.Errorf("docker daemon out of memory. No space left on device"))
}

if percentageFull > 80 {
priyawadhwa marked this conversation as resolved.
Show resolved Hide resolved
out.WarningT("The docker daemon is almost out of memory, run 'docker system prune' to free up space")
priyawadhwa marked this conversation as resolved.
Show resolved Hide resolved
}
}

// 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)
Expand Down
15 changes: 15 additions & 0 deletions pkg/minikube/problem/err_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
}
1 change: 1 addition & 0 deletions pkg/minikube/problem/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func FromError(err error, goos string) *Problem {
netProblems,
deployProblems,
stateProblems,
dockerProblems,
}

var osMatch *Problem
Expand Down