Repository: libcloud
Updated Branches:
  refs/heads/trunk 0f369d715 -> 907cdcee7


Fix a possible race condition in deploy_node which would occur if node
is online and can be accessed via SSH, but the SSH key we want to use hasn't
been installed yet.

Closes #331

Signed-off-by: Tomaz Muraus <to...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/907cdcee
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/907cdcee
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/907cdcee

Branch: refs/heads/trunk
Commit: 907cdcee71d34b876923eb9a586426d02068db1e
Parents: 0f369d7
Author: David Gay <oddsho...@riseup.net>
Authored: Sat Jun 28 14:41:17 2014 -0400
Committer: Tomaz Muraus <to...@apache.org>
Committed: Mon Jun 30 12:17:26 2014 +0200

----------------------------------------------------------------------
 CHANGES.rst              |  9 +++++++++
 libcloud/compute/base.py | 14 ++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/907cdcee/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 84e2b91..bc28e97 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -33,6 +33,15 @@ Compute
   (GITHUB-315)
   [Marcus Devich]
 
+- Fix a possible race condition in deploy_node which would occur if node
+  is online and can be accessed via SSH, but the SSH key we want to use hasn't
+  been installed yet.
+
+  Previously, we would immediately throw if we can connect, but the SSH key
+  hasn't been installed yet.
+  (GITHUB-331)
+  [David Gay]
+
 Changes with Apache Libcloud 0.15.0
 -----------------------------------
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/907cdcee/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 142c2cb..99523ac 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -35,10 +35,17 @@ from libcloud.compute.ssh import SSHClient
 from libcloud.common.base import ConnectionKey
 from libcloud.common.base import BaseDriver
 from libcloud.common.types import LibcloudError
+from libcloud.compute.ssh import have_paramiko
 
 from libcloud.utils.networking import is_private_subnet
 from libcloud.utils.networking import is_valid_ip_address
 
+if have_paramiko:
+    from paramiko.ssh_exception import SSHException
+    SSH_TIMEOUT_EXCEPTION_CLASSES = (SSHException, IOError, socket.gaierror,
+                                     socket.error)
+else:
+    SSH_TIMEOUT_EXCEPTION_CLASSES = (IOError, socket.gaierror, socket.error)
 
 # How long to wait for the node to come online after creating it
 NODE_ONLINE_WAIT_TIMEOUT = 10 * 60
@@ -1372,9 +1379,9 @@ class NodeDriver(BaseDriver):
         while time.time() < end:
             try:
                 ssh_client.connect()
-            except (IOError, socket.gaierror, socket.error):
-                # Retry if a connection is refused or timeout
-                # occurred
+            except SSH_TIMEOUT_EXCEPTION_CLASSES:
+                # Retry if a connection is refused, timeout occurred,
+                # or the connection fails due to failed authentication.
                 ssh_client.close()
                 time.sleep(wait_period)
                 continue
@@ -1401,7 +1408,6 @@ class NodeDriver(BaseDriver):
                                key_files=ssh_key_file,
                                timeout=ssh_timeout)
 
-        # Connect to the SSH server running on the node
         ssh_client = self._ssh_client_connect(ssh_client=ssh_client,
                                               timeout=timeout)
 

Reply via email to