Skip to content

Commit

Permalink
Merge pull request #8547 from tstromberg/cherry-94da4
Browse files Browse the repository at this point in the history
virtualbox: double health check timeout, add better errors
  • Loading branch information
medyagh authored Jun 24, 2020
2 parents 4f6a9f6 + a0817b6 commit c84cd3f
Showing 1 changed file with 21 additions and 5 deletions.
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}
}

0 comments on commit c84cd3f

Please sign in to comment.