diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index 06f1e31f67e6..a24c72aeed02 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -23,6 +23,7 @@ import ( "sort" "strconv" "strings" + "time" "golang.org/x/text/cases" "golang.org/x/text/language" @@ -354,12 +355,25 @@ func Suggest(options []registry.DriverState) (registry.DriverState, []registry.D // Status returns the status of a driver func Status(name string) registry.DriverState { d := registry.Driver(name) - return registry.DriverState{ - Name: d.Name, - Default: d.Default, - Priority: d.Priority, - State: registry.Status(name), + stateChannel := make(chan registry.State) + timeoutChannel := time.After(20 * time.Second) + go func() { + stateChannel <- registry.Status(name) + }() + select { + case s := <-stateChannel: + return registry.DriverState{ + Name: d.Name, + Default: d.Default, + Priority: d.Priority, + State: s, + } + case <-timeoutChannel: + klog.Infof("time out when checking for status of %s driver", name) + return registry.DriverState{} + } + } // IsAlias checks if an alias belongs to provided driver by name. diff --git a/pkg/minikube/registry/global.go b/pkg/minikube/registry/global.go index e3de3fdf93c5..77b8f35f7928 100644 --- a/pkg/minikube/registry/global.go +++ b/pkg/minikube/registry/global.go @@ -20,6 +20,7 @@ import ( "fmt" "os" "sort" + "time" "k8s.io/klog/v2" "k8s.io/minikube/pkg/minikube/translate" @@ -118,7 +119,17 @@ func Available(vm bool) []DriverState { klog.Errorf("%q does not implement Status", d.Name) continue } - s := d.Status() + stateChannel := make(chan State) + timeoutChannel := time.After(20 * time.Second) + go func() { + stateChannel <- d.Status() + }() + s := State{} + select { + case <-timeoutChannel: + klog.Infof("%s status check timeout!", d.Name) + case s = <-stateChannel: + } klog.Infof("%s default: %v priority: %d, state: %+v", d.Name, d.Default, d.Priority, s) preference := d.Priority