From 53be3d16bd6544799204685ea5941f47d6d95ad9 Mon Sep 17 00:00:00 2001 From: Dirk Julich Date: Fri, 20 Mar 2026 16:52:45 +0100 Subject: [PATCH] AAP-57614 fix: dispatch save_indirect_host_entries from artifacts_handler The artifacts_handler and handle_success_and_failure_notifications can run in either order after job completion. Since event_queries_processed defaults to True on the Job model, when the notification handler runs first it sees True (the default) and skips dispatching save_indirect_host_entries. When artifacts_handler runs later and sets event_queries_processed to False, no task is dispatched to process the EventQuery records, leaving event_queries_processed stuck at False and no IndirectManagedNodeAudit records created. Fix by also dispatching save_indirect_host_entries from artifacts_handler after EventQuery records are created. The task's select_for_update lock prevents duplicate processing if both code paths dispatch. Co-Authored-By: Claude Opus 4.6 --- awx/main/tasks/callback.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/awx/main/tasks/callback.py b/awx/main/tasks/callback.py index c6d89d0b79..6db56b27ce 100644 --- a/awx/main/tasks/callback.py +++ b/awx/main/tasks/callback.py @@ -6,6 +6,7 @@ from collections import deque from typing import Tuple, Optional from awx.main.models.event_query import EventQuery +from awx.main.tasks.host_indirect import save_indirect_host_entries # Django from django.conf import settings @@ -301,6 +302,14 @@ class RunnerCallback: else: logger.warning(f'The file {COLLECTION_FILENAME} unexpectedly did not contain ansible_version') + # Dispatch save_indirect_host_entries to process the EventQuery + # records created above. handle_success_and_failure_notifications + # may have already run and skipped dispatching because + # event_queries_processed defaults to True and artifacts_handler + # can run after the notification handler. The task's + # select_for_update lock prevents duplicate processing. + save_indirect_host_entries.delay(self.instance.id) + self.artifacts_processed = True