You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/05/14 11:14:56 UTC

svn commit: r1102979 - /incubator/libcloud/trunk/libcloud/compute/base.py

Author: tomaz
Date: Sat May 14 09:14:55 2011
New Revision: 1102979

URL: http://svn.apache.org/viewvc?rev=1102979&view=rev
Log:
Simply deploy_node a bit and actually retry the process if it fails.

Modified:
    incubator/libcloud/trunk/libcloud/compute/base.py

Modified: incubator/libcloud/trunk/libcloud/compute/base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/compute/base.py?rev=1102979&r1=1102978&r2=1102979&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/compute/base.py (original)
+++ incubator/libcloud/trunk/libcloud/compute/base.py Sat May 14 09:14:55 2011
@@ -546,29 +546,28 @@ class NodeDriver(object):
                                        port=ssh_port, username=ssh_username,
                                        password=password,
                                        timeout=kwargs.get('ssh_timeout', None))
-                    laste = None
+
                     while time.time() < end:
-                        laste = None
                         try:
                             client.connect()
-                            break
                         except (IOError, socket.gaierror, socket.error), e:
-                            laste = e
+                            # Retry if a connection is refused or timeout
+                            # occured
+                            client.close()
                             time.sleep(WAIT_PERIOD)
-                            if laste is not None:
-                                raise e
+                            continue
 
-                            tries = 3
-                            while tries >= 0:
-                                try:
-                                    n = kwargs["deploy"].run(node, client)
-                                    client.close()
-                                    break
-                                except Exception, e:
-                                    tries -= 1
-                                    if tries == 0:
-                                        raise
-                                    client.connect()
+                        max_tries, tries = 3, 0
+                        while tries < max_tries:
+                            try:
+                                n = kwargs["deploy"].run(node, client)
+                                client.close()
+                                raise
+                            except Exception, e:
+                                tries += 1
+                                if tries >= max_tries:
+                                    raise DeploymentError(node,
+                                          'Failed after %d tries' % (max_tries))
 
         except DeploymentError:
             raise