runqueue: Print pseudo.log if fakeroot task failed
PATCH 1/1 runqueue: Print pseudo.log if fakeroot task failed
Currently if pseudo fails we can only see the path to pseudo.log. If we have no access to server and can only rely on bitbake log then debugging becomes impossible. This printing needs to be added in runqueue level, not inside task execution, because in some cases task fails with pseudo abort really early and we don't even see any log.
In this change I'm adding pseudo log printing in every fakeroot task failure that logged mismatch, error or fatal to logfile, because we have no other way to communicate with pseudo if it failed or not. Only lines from last pseudo server execution will be printed.
Signed-off-by Tomasz Dziendzielski <[email protected]>
Signed-off-by Jan Brzezanski <[email protected]>
Signed-off-by Adrian Walag
Signed-off-by Paulo Neves <[email protected]>
Signed-off-by Mikolaj Lasota <[email protected]>
Signed-off-by Wiktor Baura <[email protected]>
Signed-off-by Kamil Kwiek <[email protected]>
--- lib/bb/runqueue.py | 52 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 13 deletions(-)
lib/bb/runqueue.py +39 -13
@@ -1237,11 +1237,12 @@ class RunQueue: self.worker = {} self.fakeworker = {} - def _start_worker(self, mc, fakeroot = False, rqexec = None): + def _start_worker(self, mc, fakeroot = False, rqexec = None, taskfn=None): logger.debug("Starting bitbake-worker") magic = "decafbad" if self.cooker.configuration.profile: magic = "decafbadbad" + fakerootdir = None if fakeroot: magic = magic + "beef" mcdata = self.cooker.databuilder.mcdata[mc]
@@ -1251,10 +1252,12 @@ class RunQueue: for key, value in (var.split('=') for var in fakerootenv): env[key] = value worker = subprocess.Popen(fakerootcmd + ["bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env) + if taskfn and taskfn in self.rqdata.dataCaches[mc].fakerootdirs: + fakerootdir = self.rqdata.dataCaches[mc].fakerootdirs[taskfn] else: worker = subprocess.Popen(["bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE) bb.utils.nonblockingfd(worker.stdout) - workerpipe = runQueuePipe(worker.stdout, None, self.cfgData, self, rqexec) + workerpipe = runQueuePipe(worker.stdout, None, self.cfgData, self, rqexec, fakerootdir=fakerootdir) workerdata = { "taskdeps" : self.rqdata.dataCaches[mc].task_deps,
@@ -1305,9 +1308,9 @@ class RunQueue: for mc in self.rqdata.dataCaches: self.worker[mc] = self._start_worker(mc) - def start_fakeworker(self, rqexec, mc): + def start_fakeworker(self, rqexec, mc, taskfn=None): if not mc in self.fakeworker: - self.fakeworker[mc] = self._start_worker(mc, True, rqexec) + self.fakeworker[mc] = self._start_worker(mc, True, rqexec, taskfn=taskfn) def teardown_workers(self): self.teardown = True
@@ -1772,7 +1775,7 @@ class RunQueueExecute: self.sqdata = SQData() build_scenequeue_data(self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self) - def runqueue_process_waitpid(self, task, status): + def runqueue_process_waitpid(self, task, status, fakerootdir=None): # self.build_stamps[pid] may not exist when use shared work directory. if task in self.build_stamps:
@@ -1787,7 +1790,7 @@ class RunQueueExecute: self.sq_live.remove(task) else: if status != 0: - self.task_fail(task, status) + self.task_fail(task, status, fakerootdir=fakerootdir) else: self.task_complete(task) return True
@@ -1908,14 +1911,32 @@ class RunQueueExecute: self.task_completeoutright(task) self.runq_tasksrun.add(task) - def task_fail(self, task, exitcode): + def task_fail(self, task, exitcode, fakerootdir=None): """ Called when a task has failed Updates the state engine with the failure """ self.stats.taskFailed() self.failed_tids.append(task) - bb.event.fire(runQueueTaskFailed(task, self.stats, exitcode, self.rq), self.cfgData) + + pseudo_log = "" + if fakerootdir and os.path.exists(os.path.join(fakerootdir, "pseudo.log")): + with open(os.path.join(fakerootdir, "pseudo.log")) as pseudo_log_file: + + pseudo_failed = False + for line in reversed(pseudo_log_file.readlines()): + for pseudo_error in ['mismatch', 'error', 'fatal']: + if pseudo_error in line.lower(): + pseudo_failed = True + if 'doing new pid setup and server start' in line: + break + pseudo_log = line + pseudo_log + + if not pseudo_failed: + pseudo_log = None + + bb.event.fire(runQueueTaskFailed(task, self.stats, exitcode, self.rq, pseudo_log=pseudo_log), self.cfgData) + if self.rqdata.taskData[''].abort: self.rq.state = runQueueCleanUp
@@ -2132,7 +2153,7 @@ class RunQueueExecute: if 'fakeroot' in taskdep and taskname in taskdep['fakeroot'] and not (self.cooker.configuration.dry_run or self.rqdata.setscene_enforce): if not mc in self.rq.fakeworker: try: - self.rq.start_fakeworker(self, mc) + self.rq.start_fakeworker(self, mc, taskfn=taskfn) except OSError as exc: logger.critical("Failed to spawn fakeroot worker to run %s: %s" % (task, str(exc))) self.rq.state = runQueueFailed
@@ -2876,12 +2897,16 @@ class runQueueTaskFailed(runQueueEvent): """ Event notifying a task failed """ - def __init__(self, task, stats, exitcode, rq): + def __init__(self, task, stats, exitcode, rq, pseudo_log=None): runQueueEvent.__init__(self, task, stats, rq) self.exitcode = exitcode + self.pseudo_log = pseudo_log def __str__(self): - return "Task (%s) failed with exit code '%s'" % (self.taskstring, self.exitcode) + if self.pseudo_log: + return "Task (%s) failed with exit code '%s' \nPseudo log:\n%s" % (self.taskstring, self.exitcode, self.pseudo_log) + else: + return "Task (%s) failed with exit code '%s'" % (self.taskstring, self.exitcode) class sceneQueueTaskFailed(sceneQueueEvent): """
@@ -2933,7 +2958,7 @@ class runQueuePipe(): """ Abstraction for a pipe between a worker thread and the server """ - def __init__(self, pipein, pipeout, d, rq, rqexec): + def __init__(self, pipein, pipeout, d, rq, rqexec, fakerootdir=None): self.input = pipein if pipeout: pipeout.close()
@@ -2942,6 +2967,7 @@ class runQueuePipe(): self.d = d self.rq = rq self.rqexec = rqexec + self.fakerootdir = fakerootdir def setrunqueueexec(self, rqexec): self.rqexec = rqexec
@@ -2987,7 +3013,7 @@ class runQueuePipe(): task, status = pickle.loads(self.queue[10:index]) except (ValueError, pickle.UnpicklingError, AttributeError, IndexError) as e: bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[10:index])) - self.rqexec.runqueue_process_waitpid(task, status) + self.rqexec.runqueue_process_waitpid(task, status, fakerootdir=self.fakerootdir) found = True self.queue = self.queue[index+11:] index = self.queue.find(b"</exitcode>")
Signature · 1 line
2.30.1