From bce51c53a0ab5c95d863955067e44bb309f5d1a1 Mon Sep 17 00:00:00 2001 From: Georgy Dyuldin Date: Mon, 22 Aug 2016 15:28:46 +0300 Subject: [PATCH] Fix exec_command to hang indefinitely Execution `recv_exit_status` before reading from channel may cause it hang indefinitely. Change-Id: I24dd3802133509f250659582ffb7d7f759e80988 Closes-Bug: #1615659 --- tempest/lib/common/ssh.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tempest/lib/common/ssh.py b/tempest/lib/common/ssh.py index a831dbda11..8e8377589a 100644 --- a/tempest/lib/common/ssh.py +++ b/tempest/lib/common/ssh.py @@ -121,7 +121,6 @@ class Client(object): channel.fileno() # Register event pipe channel.exec_command(cmd) channel.shutdown_write() - exit_status = channel.recv_exit_status() # If the executing host is linux-based, poll the channel if self._can_system_poll(): @@ -162,6 +161,8 @@ class Client(object): out_data = out_data.decode(encoding) err_data = err_data.decode(encoding) + exit_status = channel.recv_exit_status() + if 0 != exit_status: raise exceptions.SSHExecCommandFailed( command=cmd, exit_status=exit_status,