From 96d992c8ca7798fdb24fcd58a8648374417f4c98 Mon Sep 17 00:00:00 2001 From: Song Shukun Date: Thu, 20 Feb 2020 17:11:06 +0900 Subject: [PATCH 1/2] Increase detection timeout from 2s to 4s for hyperV --- pkg/minikube/registry/drvs/hyperv/hyperv.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/minikube/registry/drvs/hyperv/hyperv.go b/pkg/minikube/registry/drvs/hyperv/hyperv.go index 9f15d0c47007..3b448990ec1f 100644 --- a/pkg/minikube/registry/drvs/hyperv/hyperv.go +++ b/pkg/minikube/registry/drvs/hyperv/hyperv.go @@ -85,14 +85,23 @@ func status() registry.State { return registry.State{Error: err} } - // Allow no more than 2 seconds for querying state - ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + // Allow no more than 4 seconds for querying state + ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second) defer cancel() cmd := exec.CommandContext(ctx, path, "Get-WindowsOptionalFeature", "-FeatureName", "Microsoft-Hyper-V-All", "-Online") out, err := cmd.CombinedOutput() if err != nil { - return registry.State{Installed: false, Error: fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out), Fix: "Start PowerShell as Administrator, and run: 'Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All'", Doc: docURL} + errorMessage := fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out) + fixMessage := "Start PowerShell as Administrator, and run: 'Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All'" + + // If timed out, prompt different error and suggestion messages + // See https://github.com/kubernetes/minikube/issues/6579 + if ctx.Err() != nil { + errorMessage = fmt.Errorf("%s exited unexpectedly:\n%s", strings.Join(cmd.Args, " "), ctx.Err()) + fixMessage = "If you have Hyper-V configured correctly, please try start again with `--force` specified" + } + return registry.State{Installed: false, Error: errorMessage, Fix: fixMessage, Doc: docURL} } return registry.State{Installed: true, Healthy: true} } From 38437b2fa46a3238a346b927886e0df9227d0ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Str=C3=B6mberg?= Date: Thu, 20 Feb 2020 11:16:58 -0800 Subject: [PATCH 2/2] Set timeout to an outrageous 8s, based on the bug --- pkg/minikube/registry/drvs/hyperv/hyperv.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/minikube/registry/drvs/hyperv/hyperv.go b/pkg/minikube/registry/drvs/hyperv/hyperv.go index 3b448990ec1f..0aa426e76698 100644 --- a/pkg/minikube/registry/drvs/hyperv/hyperv.go +++ b/pkg/minikube/registry/drvs/hyperv/hyperv.go @@ -85,8 +85,7 @@ func status() registry.State { return registry.State{Error: err} } - // Allow no more than 4 seconds for querying state - ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second) defer cancel() cmd := exec.CommandContext(ctx, path, "Get-WindowsOptionalFeature", "-FeatureName", "Microsoft-Hyper-V-All", "-Online")