From 1963731f7de0e6fc97e2771a043aba60d49a91e8 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 19 Feb 2014 15:19:57 -0500 Subject: [PATCH] Retry ssh connections on auth failure. Some cloud instance types (Fedora for example) create the ssh user after sshd comes online. This allows our ssh connection retry loop to handle this scenario gracefully. Change-Id: Ie345dea50fc2983112cd2e72826a708583d2712a --- nodepool/nodeutils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nodepool/nodeutils.py b/nodepool/nodeutils.py index 05d32c55e..9762af3eb 100644 --- a/nodepool/nodeutils.py +++ b/nodepool/nodeutils.py @@ -23,6 +23,7 @@ import logging from sshclient import SSHClient import fakeprovider +import paramiko log = logging.getLogger("nodepool.utils") @@ -46,6 +47,10 @@ def ssh_connect(ip, username, connect_kwargs={}, timeout=60): try: client = SSHClient(ip, username, **connect_kwargs) break + except paramiko.AuthenticationException, e: + # This covers the case where the cloud user is created + # after sshd is up (Fedora for example) + log.info('Password auth exception. Try number %i...' % count) except socket.error, e: if e[0] not in [errno.ECONNREFUSED, errno.EHOSTUNREACH]: log.exception('Exception while testing ssh access:')