mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
AAP-57614 fix: remove early dispatch, rely on events_processed_hook
Dispatching save_indirect_host_entries from artifacts_handler was fundamentally flawed: it ran before job events were written to the DB by the callback receiver, so the task found no events to process, set event_queries_processed=True, and blocked all future processing. Remove the dispatch and the now-unused import. The existing events_processed_hook (called from both the task runner after the final save and the callback receiver after the wrapup event) handles dispatching at the right time — after events are in the DB. The direct DB write of event_queries_processed=False and installed_collections (added in the previous commit) remains: it ensures events_processed_hook sees the correct values regardless of which call site runs first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,6 @@ from collections import deque
|
|||||||
from typing import Tuple, Optional
|
from typing import Tuple, Optional
|
||||||
|
|
||||||
from awx.main.models.event_query import EventQuery
|
from awx.main.models.event_query import EventQuery
|
||||||
from awx.main.tasks.host_indirect import save_indirect_host_entries
|
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -302,12 +301,16 @@ class RunnerCallback:
|
|||||||
logger.warning(f'The file {COLLECTION_FILENAME} unexpectedly did not contain ansible_version')
|
logger.warning(f'The file {COLLECTION_FILENAME} unexpectedly did not contain ansible_version')
|
||||||
|
|
||||||
# Write event_queries_processed and installed_collections directly
|
# Write event_queries_processed and installed_collections directly
|
||||||
# to the DB rather than using delay_update alone. delay_update
|
# to the DB instead of using delay_update. delay_update defers
|
||||||
# only writes when the final job status is saved, but
|
# writes until the final job status save, but
|
||||||
# save_indirect_host_entries needs both values in the DB
|
# events_processed_hook (called from both the task runner after
|
||||||
# immediately: event_queries_processed=False to pass the
|
# the final save and the callback receiver after the wrapup
|
||||||
# select_for_update gate, and installed_collections to find
|
# event) needs event_queries_processed=False visible in the DB
|
||||||
# matching EventQuery records via fetch_job_event_query.
|
# to dispatch save_indirect_host_entries. The field defaults to
|
||||||
|
# True, so without a direct write the hook would see True and
|
||||||
|
# skip the dispatch. installed_collections is also written
|
||||||
|
# directly so it is available if the callback receiver
|
||||||
|
# dispatches before the final save.
|
||||||
from awx.main.models import Job
|
from awx.main.models import Job
|
||||||
|
|
||||||
db_updates = {'event_queries_processed': False}
|
db_updates = {'event_queries_processed': False}
|
||||||
@@ -315,14 +318,6 @@ class RunnerCallback:
|
|||||||
db_updates['installed_collections'] = query_file_contents['installed_collections']
|
db_updates['installed_collections'] = query_file_contents['installed_collections']
|
||||||
Job.objects.filter(id=self.instance.id).update(**db_updates)
|
Job.objects.filter(id=self.instance.id).update(**db_updates)
|
||||||
|
|
||||||
# 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
|
self.artifacts_processed = True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user