From 1e00529fac9ac9dbf867c7b774faf5f7d89cac02 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 27 Jun 2014 13:47:20 -0400 Subject: [PATCH] Fix an issue where we weren't creating job events for hosts that didn't exist in our inventory --- awx/main/models/jobs.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index bdb97e5ae0..a758497892 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -670,9 +670,11 @@ class JobEvent(CreatedModifiedModel): try: if not self.host_id and self.host_name: host_qs = Host.objects.filter(inventory__jobs__id=self.job_id, name=self.host_name) - self.host_id = host_qs.only('id').values_list('id', flat=True)[0] - if 'host_id' not in update_fields: - update_fields.append('host_id') + host_id = host_qs.only('id').values_list('id', flat=True) + if host_id.exists(): + self.host_id = host_id[0] + if 'host_id' not in update_fields: + update_fields.append('host_id') except (IndexError, AttributeError): pass if self.parent is None: