Commit b4d3d8a9 authored by Anael Beutot's avatar Anael Beutot
Browse files

Fix error reporting for ForkedJob (parent error)

parent a4c1c017
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import sys
from threading import Thread, Event

from cloudcontrol.node.exc import JobError
from cloudcontrol.node.utils import num_to_sig


logger = logging.getLogger(__name__)
@@ -240,8 +241,9 @@ class ForkedJob(object):
            for fd in self.open_fds:
                try:
                    os.close(fd)
                except OSError:
                    logger.error('Error while closing fds in parent')
                except OSError as exc:
                    logger.error('Error while closing fds in parent: %s',
                                 os.strerror(exc.errno))
                    raise

    def start(self):
@@ -281,8 +283,12 @@ class ForkedJob(object):
                    break
            assert pid == self.fork_pid
            if return_status >> 8 != 0:
                raise JobError('Exception during job, returned %s',
                               return_status)
                if return_status & 0xff == signal.SIGKILL:
                    logger.error('Job was killed')
                else:
                    raise JobError('Exception during job, returned %s, signal %s',
                                   return_status,
                                   num_to_sig(return_status & 0xff))
        finally:
            self.fork_pid = None
            self.job_done.set()