Skip to content
This repository
Browse code

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
Mitchell Hashimoto authored August 29, 2012
2  CHANGELOG.md
Source Rendered
@@ -42,6 +42,8 @@
42 42
     "localhost" is not available. [GH-1057]
43 43
   - Sending a SIGINT (Ctrl-C) very early on when executing `vagrant` no
44 44
     longer results in an ugly stack trace.
  45
+  - SSH retries in the face of a `EHOSTUNREACH` error, improving the robustness
  46
+    that SSHing succeeds when booting a machine.
45 47
 
46 48
 ## 1.0.3 (May 1, 2012)
47 49
 
11  plugins/communicators/ssh/communicator.rb
@@ -151,7 +151,16 @@ def connect
151 151
         # Connect to SSH, giving it a few tries
152 152
         connection = nil
153 153
         begin
154  
-          exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect, Timeout::Error]
  154
+          # These are the exceptions that we retry because they represent
  155
+          # errors that are generally fixed from a retry and don't
  156
+          # necessarily represent immediate failure cases.
  157
+          exceptions = [
  158
+            Errno::ECONNREFUSED,
  159
+            Errno::EHOSTUNREACH,
  160
+            Net::SSH::Disconnect,
  161
+            Timeout::Error
  162
+          ]
  163
+
155 164
           connection = retryable(:tries => @machine.config.ssh.max_tries, :on => exceptions) do
156 165
             Timeout.timeout(@machine.config.ssh.timeout) do
157 166
               @logger.info("Attempting to connect to SSH: #{ssh_info[:host]}:#{ssh_info[:port]}")

0 notes on commit 5691df3

Please sign in to comment.
Something went wrong with that request. Please try again.