From dddf1ceb29e36c799d144d1a34b951af5d10cfb7 Mon Sep 17 00:00:00 2001 From: Valerii Ponomarov Date: Wed, 22 May 2019 18:01:14 +0530 Subject: 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 --- openshift-storage-libs/openshiftstoragelibs/command.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'openshift-storage-libs') 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)) -- cgit