From 2837b110ae8fd5ff0ca3ac5959cadb7d4a5ce6cc Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Mon, 13 Oct 2014 17:10:39 +0100 Subject: bitbake: toaster: change startup parameter passing to avoid race We avoid a race between the setting the TOASTER_BRBE variable and reading the variable in toaster ui by supplying the variable at server startup time through the toaster.conf post-read file. Additional small changes are included, including marking the build request with the environment id of where the build took place. (Bitbake rev: 7c333350418c4140e6c988c5272940f8057d327d) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/buildinfohelper.py | 13 ++++++++----- bitbake/lib/bb/ui/toasterui.py | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'bitbake/lib/bb') diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index 1f66595887..fcef53b63d 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py @@ -933,14 +933,17 @@ class BuildInfoHelper(object): self.internal_state['recipes'], ) - def _store_build_done(self): + def _store_build_done(self, errorcode): br_id, be_id = self.brbe.split(":") from bldcontrol.models import BuildEnvironment, BuildRequest be = BuildEnvironment.objects.get(pk = be_id) be.lock = BuildEnvironment.LOCK_LOCK be.save() br = BuildRequest.objects.get(pk = br_id) - br.state = BuildRequest.REQ_COMPLETED + if errorcode == 0: + br.state = BuildRequest.REQ_COMPLETED + else: + br.state = BuildRequest.REQ_FAILED br.save() @@ -964,7 +967,7 @@ class BuildInfoHelper(object): self.internal_state['backlog'].append(event) else: # we're under Toaster control, post the errors to the build request from bldcontrol.models import BuildRequest, BRError - br, be = brbe.split(":") + br, be = self.brbe.split(":") buildrequest = BuildRequest.objects.get(pk = br) brerror = BRError.objects.create(req = buildrequest, errtype="build", errmsg = event.msg) @@ -992,9 +995,9 @@ class BuildInfoHelper(object): log_information['lineno'] = event.lineno self.orm_wrapper.create_logmessage(log_information) - def close(self): + def close(self, errorcode): if self.brbe is not None: - buildinfohelper._store_build_done() + self._store_build_done(errorcode) if 'backlog' in self.internal_state: for event in self.internal_state['backlog']: diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py index d81b8a989c..0c53843149 100644 --- a/bitbake/lib/bb/ui/toasterui.py +++ b/bitbake/lib/bb/ui/toasterui.py @@ -219,6 +219,7 @@ def main(server, eventHandler, params ): if isinstance(event, (bb.command.CommandCompleted, bb.command.CommandFailed, bb.command.CommandExit)): + errorcode = 0 if (isinstance(event, bb.command.CommandFailed)): event.levelno = format.ERROR event.msg = "Command Failed " + event.error @@ -226,10 +227,10 @@ def main(server, eventHandler, params ): event.lineno = 0 buildinfohelper.store_log_event(event) errors += 1 + errorcode = 1 buildinfohelper.update_build_information(event, errors, warnings, taskfailures) - buildinfohelper.close() - + buildinfohelper.close(errorcode) # we start a new build info if buildinfohelper.brbe is not None: -- cgit v1.2.3-54-g00ecf