Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Retry SSH on EHOSTUNREACH

This is one of those errors that happens once in awhile that can be
retried.
  • Loading branch information...
commit 5691df37a15cc5f9066f61b9edd8983dd9f62b97 1 parent ed1bc58
@mitchellh authored
Showing with 12 additions and 1 deletion.
  1. +2 −0  CHANGELOG.md
  2. +10 −1 plugins/communicators/ssh/communicator.rb
View
2  CHANGELOG.md
@@ -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
11 plugins/communicators/ssh/communicator.rb
@@ -151,7 +151,16 @@ def connect
# 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]}")
Please sign in to comment.
Something went wrong with that request. Please try again.