Retry SSH on EHOSTUNREACH

This is one of those errors that happens once in awhile that can be
retried.
This commit is contained in:
Mitchell Hashimoto 2012-08-29 13:39:03 -07:00
parent ed1bc58735
commit 5691df37a1
2 changed files with 12 additions and 1 deletions

View File

@ -42,6 +42,8 @@
"localhost" is not available. [GH-1057]
- Sending a SIGINT (Ctrl-C) very early on when executing `vagrant` no
longer results in an ugly stack trace.
- SSH retries in the face of a `EHOSTUNREACH` error, improving the robustness
that SSHing succeeds when booting a machine.
## 1.0.3 (May 1, 2012)

View File

@ -151,7 +151,16 @@ module VagrantPlugins
# Connect to SSH, giving it a few tries
connection = nil
begin
exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect, Timeout::Error]
# These are the exceptions that we retry because they represent
# errors that are generally fixed from a retry and don't
# necessarily represent immediate failure cases.
exceptions = [
Errno::ECONNREFUSED,
Errno::EHOSTUNREACH,
Net::SSH::Disconnect,
Timeout::Error
]
connection = retryable(:tries => @machine.config.ssh.max_tries, :on => exceptions) do
Timeout.timeout(@machine.config.ssh.timeout) do
@logger.info("Attempting to connect to SSH: #{ssh_info[:host]}:#{ssh_info[:port]}")