Skip to content

Commit

Permalink
Merge pull request #5848 from hypnoglow/try-ssh-retry
Browse files Browse the repository at this point in the history
Add retry to SSH connectivity check
  • Loading branch information
tstromberg authored Nov 14, 2019
2 parents a7e5351 + 33293ed commit 1c46502
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,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:
Expand All @@ -1071,7 +1082,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 1c46502

Please sign in to comment.