Skip to content

Commit

Permalink
Retry on SSH connectivity check
Browse files Browse the repository at this point in the history
  • Loading branch information
hypnoglow committed Nov 11, 2019
1 parent 1d0ca6c commit 7a1420d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,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) {
d := net.Dialer{Timeout: 3 * time.Second}
conn, err := d.Dial("tcp", sshAddr)
if err != nil {
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:
Expand All @@ -1062,7 +1072,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) {
Expand Down

0 comments on commit 7a1420d

Please sign in to comment.