From: Radek Pazdera <rpazdera(a)redhat.com>
This patch fixes problem with haning processes on slave machines,
after remote test execution using the -e option of nettestctl.py.
The problem is, when `ssh' is killed on the client side, the
corresponding remote `sshd' is terminated, but it doesn't signal
bash with SIGHUP if there's no tty allocated. Which (in this case
leaves two processes hanging on the slave machine (/bin/sh and
./nettestslave.py).
The solution here is passing -t agrument to `ssh', which results
in forced allocation of pseudo-tty. There's one issue with this
solution: when the remotely executed command finishes, `ssh'
terminates the connection which reults in printing "Connection
closed by remote host" even if everything was ok (return code 0).
So I also had to remove the error check associated with this
message. But I tested this and it still works fine, because
if the connection is closed by error, `ssh' exits with 255,
LNST can recognize that and still report it as an error.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
Common/SshUtils.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Common/SshUtils.py b/Common/SshUtils.py
index 109af71..e306976 100644
--- a/Common/SshUtils.py
+++ b/Common/SshUtils.py
@@ -142,7 +142,8 @@ def _remote_login(session, username, password, prompt, timeout=10):
msg = "Got username prompt after password prompt"
raise LoginAuthenticationError(msg, text)
elif match == 3: # "Connection closed"
- raise LoginError("Client said 'connection closed'",
text)
+ logging.log(logging.INFO, "Remote command execution
successful")
+ break
elif match == 4: # "Connection refused"
raise LoginError("Client said 'connection refused'",
text)
elif match == 5: # "Please wait"
@@ -183,7 +184,7 @@ def remote_login(host, port, username, password, prompt,
linesep="\n",
command = ""
else:
command = "-C '%s'" % (command)
- cmd = ("ssh -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o
UserKnownHostsFile=/dev/null "
+ cmd = ("ssh -t -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o
UserKnownHostsFile=/dev/null "
"-p %s %s@%s %s" % #-o PreferredAuthentications=password
(port, username, host, command))
--
1.7.7.6
Show replies by date