From 33293ed68984a11a1e231e06dbc87702be514702 Mon Sep 17 00:00:00 2001 From: Igor Zibarev Date: Wed, 13 Nov 2019 22:23:50 +0300 Subject: [PATCH] Retry on SSH connectivity check --- cmd/minikube/cmd/start.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 4701dbeb71df..8e329e212e7c 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1046,8 +1046,19 @@ func validateNetwork(h *host.Host, r command.Runner) string { func trySSH(h *host.Host, ip string) { sshAddr := fmt.Sprintf("%s:22", ip) - conn, err := net.Dial("tcp", sshAddr) - if err != nil { + + dial := func() (err error) { + d := net.Dialer{Timeout: 3 * time.Second} + conn, err := d.Dial("tcp", sshAddr) + if err != nil { + out.WarningT("Unable to verify SSH connectivity: {{.error}}. Will retry...", out.V{"error": err}) + return err + } + _ = conn.Close() + return nil + } + + if err := retry.Expo(dial, time.Second, 13*time.Second); err != nil { exit.WithCodeT(exit.IO, `minikube is unable to connect to the VM: {{.error}} This is likely due to one of two reasons: @@ -1062,7 +1073,6 @@ Suggested workarounds: - Restart or reinstall {{.hypervisor}} - Use an alternative --vm-driver`, out.V{"error": err, "hypervisor": h.Driver.DriverName(), "ip": ip}) } - defer conn.Close() } func tryLookup(r command.Runner) {