Attempt to wait for job host summaries

Sometimes the job host summaries can land a little later after the job
has finished so sometimes events are still filtering in when the
notifications are triggered
This commit is contained in:
Matthew Jones
2016-08-10 11:28:09 -04:00
parent ea024c7e11
commit 8fcc194c82
2 changed files with 34 additions and 19 deletions

View File

@@ -6,6 +6,7 @@ import hmac
import json
import yaml
import logging
import time
from urlparse import urljoin
# Django
@@ -680,9 +681,17 @@ class Job(UnifiedJob, JobOptions):
dependencies.append(source.create_inventory_update(launch_type='dependency'))
return dependencies
def notification_data(self):
def notification_data(self, block=5):
data = super(Job, self).notification_data()
all_hosts = {}
# NOTE: Probably related to job event slowness, remove at some point -matburt
if block:
summaries = self.job_host_summaries.all()
while block > 0 and not len(summaries):
time.sleep(1)
block -= 1
else:
summaries = self.job_host_summaries.all()
for h in self.job_host_summaries.all():
all_hosts[h.host_name] = dict(failed=h.failed,
changed=h.changed,