]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Mention hostnames in ConnectionLostErrors
authorZack Cerza <zack.cerza@inktank.com>
Fri, 7 Nov 2014 17:13:50 +0000 (10:13 -0700)
committerZack Cerza <zack.cerza@inktank.com>
Fri, 7 Nov 2014 17:13:50 +0000 (10:13 -0700)
Signed-off-by: Zack Cerza <zack@cerza.org>
teuthology/exceptions.py
teuthology/orchestra/run.py
teuthology/orchestra/test/test_run.py

index 573c335ab32befaa2980ded03056105ec3b29f9e..bf6b49a67a6417ad47c764bf499bc27a2e3ed4ec 100644 (file)
@@ -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,
             )
 
index 6c22d0bfb14bb2425d884e77bc26e5fc2cadbf20..6f7f54889dc74e1493c801c6057bdcf031717569 100644 (file)
@@ -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
index 05de1c4d30ae86dca9316960e68b452f50137777..5132768cc6334d0ff07f3c827b5f701fec995e68 100644 (file)
@@ -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):