File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -565,7 +565,6 @@ def _update_host_summary_from_stats(self, hostnames):
565565 summaries = dict ()
566566 updated_hosts_list = list ()
567567 for host in hostnames :
568- updated_hosts_list .append (host .lower ())
569568 host_id = host_map .get (host )
570569 if host_id not in existing_host_ids :
571570 host_id = None
@@ -582,6 +581,12 @@ def _update_host_summary_from_stats(self, hostnames):
582581 summary .failed = bool (summary .dark or summary .failures )
583582 summaries [(host_id , host )] = summary
584583
584+ # do not count dark / unreachable hosts as updated
585+ if not bool (summary .dark ):
586+ updated_hosts_list .append (host .lower ())
587+ else :
588+ logger .warning (f'host { host .lower ()} is dark / unreachable, not marking it as updated' )
589+
585590 JobHostSummary .objects .bulk_create (summaries .values ())
586591
587592 # update the last_job_id and last_job_host_summary_id
Original file line number Diff line number Diff line change @@ -165,7 +165,9 @@ def test_host_metrics_update(self):
165165 skipped = dict ((hostname , len (hostname )) for hostname in self .hostnames [10 :12 ]),
166166 )
167167 assert len (HostMetric .objects .filter (Q (deleted = False ) & Q (deleted_counter = 0 ) & Q (last_deleted__isnull = True ))) == 6
168- assert len (HostMetric .objects .filter (Q (deleted = False ) & Q (deleted_counter = 1 ) & Q (last_deleted__isnull = False ))) == 6
168+
169+ # one of those 6 hosts is dark, so will not be counted
170+ assert len (HostMetric .objects .filter (Q (deleted = False ) & Q (deleted_counter = 1 ) & Q (last_deleted__isnull = False ))) == 5
169171
170172 def _generate_hosts (self , cnt , id_from = 0 ):
171173 self .hostnames = [f'Host { i } ' for i in range (id_from , id_from + cnt )]
You can’t perform that action at this time.
0 commit comments