Patchwork [bitbake-devel,15/18] toaster: select recipe based on PN name

login
register
mail settings
Submitter Alexandru DAMIAN
Date March 24, 2014, 6:37 p.m.
Message ID <e855031410daf2b99a6ca40b70956fe67c96f71c.1395686148.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/69105/
State New
Headers show

Comments

Alexandru DAMIAN - March 24, 2014, 6:37 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

When saving task stats, if there were multiple tasks executed
based on the same recipe file, we might have saved the stats
to the wrong task by selecting another recipe.

This patch takes the PN into account to properly select
the file stats.

A check is also made to make sure we don't fail saving
data due to interrupted builds.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 lib/bb/ui/buildinfohelper.py | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

Patch

diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index 30c9b92..71b2ff5 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -678,20 +678,18 @@  class BuildInfoHelper(object):
 
 
     def store_tasks_stats(self, event):
-        for (taskfile, taskname, taskstats) in event.data:
+        for (taskfile, taskname, taskstats, recipename) in event.data:
             localfilepath = taskfile.split(":")[-1]
             assert localfilepath.startswith("/")
 
             recipe_information = self._get_recipe_information_from_taskfile(taskfile)
-            try:
-                recipe = self.orm_wrapper.get_update_recipe_object(recipe_information, True)
-            except NotExisting:
-                recipe = Recipe.objects.get(layer_version = recipe_information['layer_version'],
-                            file_path__endswith = recipe_information['file_path'])
+            recipe_object = Recipe.objects.get(layer_version = recipe_information['layer_version'],
+                            file_path__endswith = recipe_information['file_path'],
+                            name = recipename)
 
             task_information = {}
             task_information['build'] = self.internal_state['build']
-            task_information['recipe'] = recipe
+            task_information['recipe'] = recipe_object
             task_information['task_name'] = taskname
             task_information['cpu_usage'] = taskstats['cpu_usage']
             task_information['disk_io'] = taskstats['disk_io']
@@ -756,11 +754,15 @@  class BuildInfoHelper(object):
         # for all image targets
         for target in self.internal_state['targets']:
             if target.is_image:
-                pkgdata = event.data['pkgdata']
-                imgdata = event.data['imgdata'][target.target]
-                self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes'])
-                filedata = event.data['filedata'][target.target]
-                self.orm_wrapper.save_target_file_information(self.internal_state['build'], target, filedata)
+                try:
+                    pkgdata = event.data['pkgdata']
+                    imgdata = event.data['imgdata'][target.target]
+                    self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes'])
+                    filedata = event.data['filedata'][target.target]
+                    self.orm_wrapper.save_target_file_information(self.internal_state['build'], target, filedata)
+                except KeyError:
+                    # we must have not got the data for this image, nothing to save
+                    pass