There were some timing issues where net/ssh could
get stuck in a loop when connecting to ubuntu.

This has been resolved by specifying a 10 second
timeout on the method call that tests the initial
connection.

Signed-off-by: Dan Bode <[email protected]>
---
 lib/puppet/cloudpack.rb |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/cloudpack.rb b/lib/puppet/cloudpack.rb
index 0f74af6..820b2ab 100644
--- a/lib/puppet/cloudpack.rb
+++ b/lib/puppet/cloudpack.rb
@@ -5,6 +5,7 @@ require 'fog'
 require 'net/ssh'
 require 'puppet/network/http_pool'
 require 'net/ssh'
+require 'timeout'
 
 module Puppet::CloudPack
   require 'puppet/cloudpack/installer'
@@ -576,7 +577,9 @@ module Puppet::CloudPack
       # We should only really block for 3 minutes or so.
       retries = 0
       begin
-        ssh_remote_execute(server, login, "date", keyfile)
+        status = Timeout::timeout(10) do
+          ssh_remote_execute(server, login, "date", keyfile)
+        end
       rescue Net::SSH::AuthenticationFailed, Errno::ECONNREFUSED => e
         if (retries += 1) > 10
           Puppet.err "Could not connect via SSH.  The error is: #{e}"
@@ -597,6 +600,15 @@ module Puppet::CloudPack
           Puppet.info "Failed to connect with issue #{e} (Retry #{retries})"
           Puppet.info "This may be because the machine is booting.  Retrying 
the connection..."
         end
+      rescue Timeout::Error => e
+        if (retries += 1) > 5
+          Puppet.err "Could not connect via SSH.  The error is: #{e}"
+          raise Puppet::Error, "Too many timeouts trying to connect."
+        else
+          Puppet.info "Connection test timed-out: (Retry #{retries})"
+          Puppet.info "This may be because the machine is booting.  Retrying 
the connection..."
+          retry
+        end
       rescue Exception => e
         Puppet.err("Unhandled connection robustness error: #{e.class} 
[#{e.inspect}]")
         raise e
-- 
1.7.5.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to