[Toaster] [PATCH 4/5] toaster: use a more straightforward query to find tasks to update
Elliot Smith
elliot.smith at intel.com
Fri Feb 19 06:49:12 PST 2016
When we get buildstats data for a task (disk IO, CPU usage etc.)
we need to find a task already associated with the build and
amend its properties with values from that data.
The existing code uses an arcane mechanism for locating the task
to be updated, which was actually creating duplicate tasks against
the build. These tasks were then not displaying in the build's "Tasks"
page.
Modify how we locate the task in the build which needs to be updated,
so that we just filter the existing tasks for the build where the
recipe matches the one in the buildstats data.
[YOCTO #8842]
Signed-off-by: Elliot Smith <elliot.smith at intel.com>
---
bitbake/lib/bb/ui/buildinfohelper.py | 40 +++++++++++++-----------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 5f079d1..89e4a08 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -1085,32 +1085,20 @@ class BuildInfoHelper(object):
def store_tasks_stats(self, event):
task_data = BuildInfoHelper._get_data_from_event(event)
- for (taskfile, taskname, taskstats, recipename) in task_data:
- localfilepath = taskfile.split(":")[-1]
- assert localfilepath.startswith("/")
-
- recipe_information = self._get_recipe_information_from_taskfile(taskfile)
- try:
- if recipe_information['file_path'].startswith(recipe_information['layer_version'].local_path):
- recipe_information['file_path'] = recipe_information['file_path'][len(recipe_information['layer_version'].local_path):].lstrip("/")
-
- recipe_object = Recipe.objects.get(layer_version = recipe_information['layer_version'],
- file_path__endswith = recipe_information['file_path'],
- name = recipename)
- except Recipe.DoesNotExist:
- logger.error("Could not find recipe for recipe_information %s name %s" , pformat(recipe_information), recipename)
- raise
-
- task_information = {}
- task_information['build'] = self.internal_state['build']
- task_information['recipe'] = recipe_object
- task_information['task_name'] = taskname
- task_information['cpu_usage'] = taskstats['cpu_usage']
- task_information['disk_io'] = taskstats['disk_io']
- if 'elapsed_time' in taskstats:
- task_information['elapsed_time'] = taskstats['elapsed_time']
-
- self.orm_wrapper.get_update_task_object(task_information, True)
+ for (taskfile, task_name, taskstats, recipename) in task_data:
+ # find the task for this build which matches the task information
+ # we're storing
+ task_to_update = Task.objects.get(
+ build = self.internal_state['build'],
+ recipe__name = recipename,
+ task_name = task_name
+ )
+
+ task_to_update.cpu_usage = taskstats['cpu_usage']
+ task_to_update.disk_io = taskstats['disk_io']
+ task_to_update.elapsed_time = taskstats['elapsed_time']
+
+ task_to_update.save()
def update_and_store_task(self, event):
assert 'taskfile' in vars(event)
--
Elliot Smith
Software Engineer
Intel OTC
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
More information about the toaster
mailing list