From: Zack Cerza Date: Fri, 7 Nov 2014 17:13:50 +0000 (-0700) Subject: Mention hostnames in ConnectionLostErrors X-Git-Tag: 1.1.0~1075 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=449de49de98a35e8a713da7bf6391e7dae0b74a4;p=teuthology.git Mention hostnames in ConnectionLostErrors Signed-off-by: Zack Cerza --- diff --git a/teuthology/exceptions.py b/teuthology/exceptions.py index 573c335a..bf6b49a6 100644 --- a/teuthology/exceptions.py +++ b/teuthology/exceptions.py @@ -58,11 +58,14 @@ class ConnectionLostError(Exception): """ Exception thrown when the connection is lost """ - def __init__(self, command): + def __init__(self, command, node=None): self.command = command + self.node = node def __str__(self): - return "SSH connection was lost: {command!r}".format( + node_str = 'to %s ' % self.node if self.node else '' + return "SSH connection {node_str}was lost: {command!r}".format( + node_str=node_str, command=self.command, ) diff --git a/teuthology/orchestra/run.py b/teuthology/orchestra/run.py index 6c22d0bf..6f7f5488 100644 --- a/teuthology/orchestra/run.py +++ b/teuthology/orchestra/run.py @@ -95,7 +95,8 @@ class RemoteProcess(object): transport = self.client.get_transport() if transport is None or not transport.is_active(): # look like we lost the connection - raise ConnectionLostError(command=self.command) + raise ConnectionLostError(command=self.command, + node=self.hostname) # connection seems healthy still, assuming it was a # signal; sadly SSH does not tell us which signal @@ -316,7 +317,7 @@ def run( try: (host, port) = client.get_transport().getpeername() except socket.error: - raise ConnectionLostError(command=quote(args)) + raise ConnectionLostError(command=quote(args), node=name) if name is None: name = host diff --git a/teuthology/orchestra/test/test_run.py b/teuthology/orchestra/test/test_run.py index 05de1c4d..5132768c 100644 --- a/teuthology/orchestra/test/test_run.py +++ b/teuthology/orchestra/test/test_run.py @@ -229,7 +229,7 @@ class TestRun(object): ) assert e.command == 'foo' - assert str(e) == "SSH connection was lost: 'foo'" + assert str(e) == "SSH connection to HOST was lost: 'foo'" @fudge.with_fakes def test_run_status_lost_socket(self):