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 2020/08/04 12:34:28 UTC

[libcloud] branch trunk updated: Try to reconnect if we receive "ssh connection not active" error during deployment step run.

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 8a6cd1e  Try to reconnect if we receive "ssh connection not active" error during deployment step run.
8a6cd1e is described below

commit 8a6cd1ec8420b07ca7930788116dffed68a03bfd
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Tue Aug 4 14:33:32 2020 +0200

    Try to reconnect if we receive "ssh connection not active" error during
    deployment step run.
    
    This may help in scenarios when connection is closed for some reason
    before finishing running all the deployment steps.
---
 libcloud/compute/base.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 44c5ade..e688e20 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -1881,6 +1881,14 @@ class NodeDriver(BaseDriver):
             except Exception as e:
                 tries += 1
 
+                if "ssh session not active" in str(e).lower():
+                    # Sometimes connection gets closed or disconnected half
+                    # way through.
+                    # If this happens, we try to re-connect before re-attempting
+                    # to run the step.
+                    ssh_client = self._ssh_client_connect(ssh_client=ssh_client,
+                                                        timeout=ssh_client.timeout)
+
                 if tries >= max_tries:
                     raise LibcloudError(value='Failed after %d tries: %s'
                                         % (max_tries, str(e)), driver=self)