libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1102979 - /incubator/libcloud/trunk/libcloud/compute/base.py
Date Sat, 14 May 2011 09:14:56 GMT
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



Mime
View raw message