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

virtualbox: double health check timeout, add better errors #8547

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Changes from all 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
26 changes: 21 additions & 5 deletions pkg/minikube/registry/drvs/virtualbox/virtualbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/docker/machine/drivers/virtualbox"
"github.com/docker/machine/libmachine/drivers"
"github.com/golang/glog"

"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/download"
Expand Down Expand Up @@ -79,19 +80,34 @@ func status() registry.State {
}

// Allow no more than 2 seconds for querying state
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, path, "list", "hostinfo")
out, err := cmd.CombinedOutput()
if err != nil {
err = cmd.Run()

// Basic timeout
if ctx.Err() == context.DeadlineExceeded {
glog.Warningf("%q timed out. ", strings.Join(cmd.Args, " "))
return registry.State{Error: err, Installed: true, Healthy: false, Fix: "Restart VirtualBox", Doc: docURL}
}

if exitErr, ok := err.(*exec.ExitError); ok {
stderr := strings.TrimSpace(string(exitErr.Stderr))
return registry.State{
Installed: true,
Error: fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out),
Fix: "Install the latest version of VirtualBox",
Error: fmt.Errorf(`%q returned: %v: %s`, strings.Join(cmd.Args, " "), exitErr, stderr),
Fix: "Restart VirtualBox, or upgrade to the latest version of VirtualBox",
Doc: docURL,
}
}

if err != nil {
return registry.State{
Installed: true,
Error: fmt.Errorf("%s failed: %v", strings.Join(cmd.Args, " "), err),
}
}

return registry.State{Installed: true, Healthy: true}
}