mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
Merge pull request #3813 from matburt/fix_smart_inventory_impact
Change host counting for task impact
This commit is contained in:
@@ -629,15 +629,17 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def task_impact(self):
|
def task_impact(self):
|
||||||
# NOTE: We sorta have to assume the host count matches and that forks default to 5
|
|
||||||
from awx.main.models.inventory import Host
|
|
||||||
if self.launch_type == 'callback':
|
if self.launch_type == 'callback':
|
||||||
count_hosts = 2
|
count_hosts = 2
|
||||||
else:
|
else:
|
||||||
count_hosts = Host.objects.filter(inventory__jobs__pk=self.pk).count()
|
# If for some reason we can't count the hosts then lets assume the impact as forks
|
||||||
if self.job_slice_count > 1:
|
if self.inventory is not None:
|
||||||
# Integer division intentional
|
count_hosts = self.inventory.hosts.count()
|
||||||
count_hosts = (count_hosts + self.job_slice_count - self.job_slice_number) // self.job_slice_count
|
if self.job_slice_count > 1:
|
||||||
|
# Integer division intentional
|
||||||
|
count_hosts = (count_hosts + self.job_slice_count - self.job_slice_number) // self.job_slice_count
|
||||||
|
else:
|
||||||
|
count_hosts = 5 if self.forks == 0 else self.forks
|
||||||
return min(count_hosts, 5 if self.forks == 0 else self.forks) + 1
|
return min(count_hosts, 5 if self.forks == 0 else self.forks) + 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Reference in New Issue
Block a user