From 1fb890f4ebe76816fe3b8fb7fc70b938bd942f2b Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 6 Dec 2017 11:27:07 -0500 Subject: [PATCH] fix a race condition in "host.last_job" when jobs are deleted see: https://github.com/ansible/ansible-tower/issues/7815 --- awx/main/signals.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/awx/main/signals.py b/awx/main/signals.py index 1936f96c76..aa5266d31a 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -296,7 +296,12 @@ def _update_host_last_jhs(host): except IndexError: jhs = None update_fields = [] - last_job = jhs.job if jhs else None + try: + last_job = jhs.job if jhs else None + except Job.DoesNotExist: + # The job (and its summaries) have already been/are currently being + # deleted, so there's no need to update the host w/ a reference to it + return if host.last_job != last_job: host.last_job = last_job update_fields.append('last_job')