]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc: simplify reconnect logic
authorJosh Durgin <josh.durgin@dreamhost.com>
Fri, 30 Dec 2011 20:23:28 +0000 (12:23 -0800)
committerJosh Durgin <josh.durgin@dreamhost.com>
Fri, 30 Dec 2011 22:37:37 +0000 (14:37 -0800)
Ignore all errors until the timeout expires so we don't have to worry
about whitelisting them.

teuthology/misc.py

index 0e6b7676c17e24622a41433e3cc1232d75c03c5a..720b115fc3204d3627fbfbaec439525554437b67 100644 (file)
@@ -4,7 +4,6 @@ import os
 import logging
 import configobj
 import getpass
-import paramiko
 import socket
 import time
 import urllib2
@@ -319,12 +318,11 @@ def reconnect(ctx, timeout):
     contains this data, you can construct a context
     that is a subset of your full cluster.
     """
-    import errno
     log.info('Re-opening connections...')
     starttime = time.time()
     need_reconnect = ctx.cluster.remotes.keys()
-    while True:
-        for remote in list(need_reconnect):
+    while need_reconnect:
+        for remote in need_reconnect:
             try:
                 log.info('trying to connect to %s', remote.name)
                 from .orchestra import connection
@@ -333,28 +331,12 @@ def reconnect(ctx, timeout):
                     host_key=ctx.config['targets'][remote.name],
                     keep_alive=True,
                     )
-            except socket.timeout:
-                pass
-            except socket.error as e:
-                if hasattr(e, '__getitem__'):
-                    if e[0] not in [errno.ECONNREFUSED, errno.ETIMEDOUT,
-                                errno.EHOSTUNREACH, errno.EHOSTDOWN]:
-                        log.exception('unknown socket error: %s', repr(e))
-                        raise
-                    else:
-                        if time.time() - starttime > timeout:
-                            raise
-                else:
-                    log.exception('weird socket error without error code')
-                    raise
-            except paramiko.SSHException:
+            except Exception:
                 if time.time() - starttime > timeout:
                     raise
             else:
                 need_reconnect.remove(remote)
 
-        if not need_reconnect:
-            break
         log.debug('waited {elapsed}'.format(elapsed=str(time.time() - starttime)))
         time.sleep(1)