@@ -25,6 +25,7 @@ import (
25
25
26
26
"github.com/docker/machine/drivers/virtualbox"
27
27
"github.com/docker/machine/libmachine/drivers"
28
+ "github.com/golang/glog"
28
29
29
30
"k8s.io/minikube/pkg/minikube/config"
30
31
"k8s.io/minikube/pkg/minikube/download"
@@ -79,19 +80,34 @@ func status() registry.State {
79
80
}
80
81
81
82
// 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 )
83
84
defer cancel ()
84
85
85
86
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 ))
88
97
return registry.State {
89
98
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" ,
92
101
Doc : docURL ,
93
102
}
94
103
}
95
104
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
+
96
112
return registry.State {Installed : true , Healthy : true }
97
113
}
0 commit comments