mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
feat: do not count dark hosts as updated (#15872)
* feat: do not count dark hosts as updated * update functional tests
This commit is contained in:
parent
5b17e5c9c3
commit
abc04e5c88
@ -565,7 +565,6 @@ class JobEvent(BasePlaybookEvent):
|
||||
summaries = dict()
|
||||
updated_hosts_list = list()
|
||||
for host in hostnames:
|
||||
updated_hosts_list.append(host.lower())
|
||||
host_id = host_map.get(host)
|
||||
if host_id not in existing_host_ids:
|
||||
host_id = None
|
||||
@ -582,6 +581,12 @@ class JobEvent(BasePlaybookEvent):
|
||||
summary.failed = bool(summary.dark or summary.failures)
|
||||
summaries[(host_id, host)] = summary
|
||||
|
||||
# do not count dark / unreachable hosts as updated
|
||||
if not bool(summary.dark):
|
||||
updated_hosts_list.append(host.lower())
|
||||
else:
|
||||
logger.warning(f'host {host.lower()} is dark / unreachable, not marking it as updated')
|
||||
|
||||
JobHostSummary.objects.bulk_create(summaries.values())
|
||||
|
||||
# update the last_job_id and last_job_host_summary_id
|
||||
|
||||
@ -165,7 +165,9 @@ class TestEvents:
|
||||
skipped=dict((hostname, len(hostname)) for hostname in self.hostnames[10:12]),
|
||||
)
|
||||
assert len(HostMetric.objects.filter(Q(deleted=False) & Q(deleted_counter=0) & Q(last_deleted__isnull=True))) == 6
|
||||
assert len(HostMetric.objects.filter(Q(deleted=False) & Q(deleted_counter=1) & Q(last_deleted__isnull=False))) == 6
|
||||
|
||||
# one of those 6 hosts is dark, so will not be counted
|
||||
assert len(HostMetric.objects.filter(Q(deleted=False) & Q(deleted_counter=1) & Q(last_deleted__isnull=False))) == 5
|
||||
|
||||
def _generate_hosts(self, cnt, id_from=0):
|
||||
self.hostnames = [f'Host {i}' for i in range(id_from, id_from + cnt)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user