Skip to content

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

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

Merged
merged 7 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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: 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
23 changes: 23 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 Down Expand Up @@ -149,6 +151,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 +205,26 @@ 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.Warning("error running df -h /var: %v", err)
}
output = strings.Trim(output, "\n")
percentageFull, err := strconv.Atoi(output[:len(output)-1])
if err != nil {
glog.Warning("error getting % of /var that is free: %v", err)
}
if percentageFull >= 99 {
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)
Expand Down
9 changes: 9 additions & 0 deletions pkg/minikube/problem/err_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,12 @@ 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(`No space left on device`),
Advice: "Run 'docker system prune' to delete unused data and free up space on the device",
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