Skip to content

Commit c84cd3f

Browse files
authored
Merge pull request #8547 from tstromberg/cherry-94da4
virtualbox: double health check timeout, add better errors
2 parents 4f6a9f6 + a0817b6 commit c84cd3f

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

pkg/minikube/registry/drvs/virtualbox/virtualbox.go

+21-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/docker/machine/drivers/virtualbox"
2727
"github.com/docker/machine/libmachine/drivers"
28+
"github.com/golang/glog"
2829

2930
"k8s.io/minikube/pkg/minikube/config"
3031
"k8s.io/minikube/pkg/minikube/download"
@@ -79,19 +80,34 @@ func status() registry.State {
7980
}
8081

8182
// Allow no more than 2 seconds for querying state
82-
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
83+
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
8384
defer cancel()
8485

8586
cmd := exec.CommandContext(ctx, path, "list", "hostinfo")
86-
out, err := cmd.CombinedOutput()
87-
if err != nil {
87+
err = cmd.Run()
88+
89+
// Basic timeout
90+
if ctx.Err() == context.DeadlineExceeded {
91+
glog.Warningf("%q timed out. ", strings.Join(cmd.Args, " "))
92+
return registry.State{Error: err, Installed: true, Healthy: false, Fix: "Restart VirtualBox", Doc: docURL}
93+
}
94+
95+
if exitErr, ok := err.(*exec.ExitError); ok {
96+
stderr := strings.TrimSpace(string(exitErr.Stderr))
8897
return registry.State{
8998
Installed: true,
90-
Error: fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out),
91-
Fix: "Install the latest version of VirtualBox",
99+
Error: fmt.Errorf(`%q returned: %v: %s`, strings.Join(cmd.Args, " "), exitErr, stderr),
100+
Fix: "Restart VirtualBox, or upgrade to the latest version of VirtualBox",
92101
Doc: docURL,
93102
}
94103
}
95104

105+
if err != nil {
106+
return registry.State{
107+
Installed: true,
108+
Error: fmt.Errorf("%s failed: %v", strings.Join(cmd.Args, " "), err),
109+
}
110+
}
111+
96112
return registry.State{Installed: true, Healthy: true}
97113
}

0 commit comments

Comments
 (0)