From 57595040cac814029b6850361608de0dee32d95e Mon Sep 17 00:00:00 2001 From: Igor Zibarev Date: Wed, 6 Nov 2019 23:39:44 +0300 Subject: [PATCH] Retry on SSH connectivity check --- cmd/minikube/cmd/start.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 523d00ba4ce7..943f9b9aa07d 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1030,8 +1030,18 @@ 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) { + dialer := net.Dialer{Timeout: 3 * time.Second} + conn, err := dialer.Dial("tcp", sshAddr) + if err != nil { + return err + } + _ = conn.Close() + return nil + } + + if err := retry.Expo(dial, time.Second, 10*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: @@ -1046,7 +1056,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) {