]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
orchestra.run: More consistently notice failures 1045/head
authorZack Cerza <zack@redhat.com>
Fri, 10 Mar 2017 23:14:30 +0000 (16:14 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 10 Mar 2017 23:18:27 +0000 (16:18 -0700)
check_status=True in combination with wait=False resulted in
CommandFailedError never being raised if poll() was used instead of
wait(). Fix that.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/run.py

index 6f829ab35ab5a6962a5d3826b7659e5a56d7bf5f..da7e1fd36f6c80ebc9343fc4f5798f9d8dbc5eb1 100644 (file)
@@ -146,8 +146,14 @@ class RemoteProcess(object):
                         not isinstance(stream_obj, ChannelFile):
                     stream_obj.seek(0)
 
+        self._raise_for_status()
+        return status
+
+    def _raise_for_status(self):
+        if self.returncode is None:
+            self._get_exitstatus()
         if self.check_status:
-            if status is None:
+            if self.returncode in (None, -1):
                 # command either died due to a signal, or the connection
                 # was lost
                 transport = self.client.get_transport()
@@ -159,11 +165,11 @@ class RemoteProcess(object):
                 # connection seems healthy still, assuming it was a
                 # signal; sadly SSH does not tell us which signal
                 raise CommandCrashedError(command=self.command)
-            if status != 0:
-                raise CommandFailedError(command=self.command,
-                                         exitstatus=status, node=self.hostname,
-                                         label=self.label)
-        return status
+            if self.returncode != 0:
+                raise CommandFailedError(
+                    command=self.command, exitstatus=self.returncode,
+                    node=self.hostname, label=self.label
+                )
 
     def _get_exitstatus(self):
         """
@@ -190,6 +196,7 @@ class RemoteProcess(object):
         :returns: self.returncode if the process is finished; else None
         """
         if self.finished:
+            self._raise_for_status()
             return self.returncode
         return None