diff options
author | Valerii Ponomarov <vponomar@redhat.com> | 2019-05-22 18:01:14 +0530 |
---|---|---|
committer | vponomar <vponomar@redhat.com> | 2019-05-24 11:14:15 +0000 |
commit | dddf1ceb29e36c799d144d1a34b951af5d10cfb7 (patch) | |
tree | 5d2c8d9f48b53ecf0de2f7dcb7c991ad783cd48e | |
parent | 6fbbd5f55db83fdaeff29e80582341b5116b616c (diff) |
Make 'command.cmd_run' func be resistable to broken SSH connections
It happens that we get "No ssh connection" errors from time to time.
So, avoid such errors recreating SSH connections if such error appears.
Change-Id: Idc71c4ceece6b3040c396b25da1deadcefd29b60
-rw-r--r-- | openshift-storage-libs/openshiftstoragelibs/command.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/command.py b/openshift-storage-libs/openshiftstoragelibs/command.py index 06912915..e75bbcaa 100644 --- a/openshift-storage-libs/openshiftstoragelibs/command.py +++ b/openshift-storage-libs/openshiftstoragelibs/command.py @@ -13,6 +13,10 @@ def cmd_run(cmd, hostname, raise_on_error=True): str: Stripped shell command's stdout value if not None. """ ret, out, err = g.run(hostname, cmd, "root") + if ("no ssh connection" in err.lower() or + "tls handshake timeout" in err.lower()): + g.ssh_close_connection(hostname) + ret, out, err = g.run(hostname, cmd, "root") if raise_on_error: msg = ("Failed to execute command '%s' on '%s' node. Got non-zero " "return code '%s'. Err: %s" % (cmd, hostname, ret, err)) |