ffdc: Enhance scp error handling
Pause for 2 seconds allowing Paramiko to finish error processing before next fetch.
Without the delay after SCPException,
next fetch will get 'paramiko.ssh_exception.SSHException'> Channel closed Error.
Test:
- Normal ./tools/myffdc.robot run
- Inject 21 'No such file' instances into scp code path via ffdc_config.yaml
Signed-off-by: Peter D Phan <peterp@us.ibm.com>
Change-Id: If3e771ed3eb0b658d3615e32360181ba88f5e3fa
diff --git a/ffdc/lib/ssh_utility.py b/ffdc/lib/ssh_utility.py
index e695f3d..01b39dd 100644
--- a/ffdc/lib/ssh_utility.py
+++ b/ffdc/lib/ssh_utility.py
@@ -148,11 +148,14 @@
try:
self.scpclient.get(remote_file, local_file, recursive=True)
- except (SCPException, SocketTimeout, PipeTimeout) as e:
+ except (SCPException, SocketTimeout, PipeTimeout, SSHException) as e:
# Log command with error. Return to caller for next file, if any.
logging.error(
"\n\tERROR: Fail scp %s from remotehost %s %s\n\n" % (remote_file, e.__class__, e))
+ # Pause for 2 seconds allowing Paramiko to finish error processing before next fetch.
+ # Without the delay after SCPException,
+ # next fetch will get 'paramiko.ssh_exception.SSHException'> Channel closed Error.
+ time.sleep(2)
return False
-
# Return True for file accounting
return True