From 116cf902b585db9a8516dc60a79a799603f54249 Mon Sep 17 00:00:00 2001 From: Matthew Jones <“mjones@ansible.com”> Date: Tue, 11 Mar 2014 16:12:22 -0400 Subject: [PATCH] Fix a bug processing dependent tasks. Fix an issue where we weren't calculating the task impact of a job properly --- awx/main/management/commands/run_task_system.py | 2 +- awx/main/models/jobs.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/awx/main/management/commands/run_task_system.py b/awx/main/management/commands/run_task_system.py index 0a991fd90c..a20eb93e80 100644 --- a/awx/main/management/commands/run_task_system.py +++ b/awx/main/management/commands/run_task_system.py @@ -177,7 +177,7 @@ def rebuild_graph(message): time_delt = len(task_dependencies) - task_dependencies.index(dep) dep.created = task.created - datetime.timedelta(seconds=1+time_delt) dep.save() - waiting_tasks.insert(dep, waiting_tasks.index(task)) + waiting_tasks.insert(waiting_tasks.index(task), dep) task.status = 'waiting' task.save() diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 760516476f..13333eb5df 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -15,6 +15,9 @@ import uuid # PyYAML import yaml +# ZMQ +import zmq + # Django from django.conf import settings from django.db import models @@ -328,7 +331,9 @@ class Job(CommonTask): @property def task_impact(self): # NOTE: We sorta have to assume the host count matches and that forks default to 5 - return min(self._get_hosts().count(), 5 if self.forks == 0 else self.forks) * 10 + from awx.main.models.inventory import Host + count_hosts = Host.objects.filter(inventory__jobs__pk=self.pk).count() + return min(count_hosts, 5 if self.forks == 0 else self.forks) * 10 @property def successful_hosts(self):