From 6d61aa16f434cdd19e72803d790f6ea3377eece1 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 10 Mar 2017 16:14:30 -0700 Subject: [PATCH] orchestra.run: More consistently notice failures 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 --- teuthology/orchestra/run.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/teuthology/orchestra/run.py b/teuthology/orchestra/run.py index 6f829ab35..da7e1fd36 100644 --- a/teuthology/orchestra/run.py +++ b/teuthology/orchestra/run.py @@ -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 -- 2.47.3