AAP-14538 Only process ansible_facts for successful jobs (#14313)

This commit is contained in:
Alan Rominger
2023-08-04 17:10:14 -04:00
committed by GitHub
parent abc56305cc
commit 6f9ea1892b
3 changed files with 6 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ class RunnerCallback:
self.model = model self.model = model
self.update_attempts = int(settings.DISPATCHER_DB_DOWNTOWN_TOLLERANCE / 5) self.update_attempts = int(settings.DISPATCHER_DB_DOWNTOWN_TOLLERANCE / 5)
self.wrapup_event_dispatched = False self.wrapup_event_dispatched = False
self.artifacts_processed = False
self.extra_update_fields = {} self.extra_update_fields = {}
def update_model(self, pk, _attempt=0, **updates): def update_model(self, pk, _attempt=0, **updates):
@@ -211,6 +212,9 @@ class RunnerCallback:
if result_traceback: if result_traceback:
self.delay_update(result_traceback=result_traceback) self.delay_update(result_traceback=result_traceback)
def artifacts_handler(self, artifact_dir):
self.artifacts_processed = True
class RunnerCallbackForProjectUpdate(RunnerCallback): class RunnerCallbackForProjectUpdate(RunnerCallback):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

View File

@@ -1094,7 +1094,7 @@ class RunJob(SourceControlMixin, BaseTask):
# actual `run()` call; this _usually_ means something failed in # actual `run()` call; this _usually_ means something failed in
# the pre_run_hook method # the pre_run_hook method
return return
if self.should_use_fact_cache(): if self.should_use_fact_cache() and self.runner_callback.artifacts_processed:
job.log_lifecycle("finish_job_fact_cache") job.log_lifecycle("finish_job_fact_cache")
finish_fact_cache( finish_fact_cache(
job.get_hosts_for_fact_cache(), job.get_hosts_for_fact_cache(),

View File

@@ -464,6 +464,7 @@ class AWXReceptorJob:
event_handler=self.task.runner_callback.event_handler, event_handler=self.task.runner_callback.event_handler,
finished_callback=self.task.runner_callback.finished_callback, finished_callback=self.task.runner_callback.finished_callback,
status_handler=self.task.runner_callback.status_handler, status_handler=self.task.runner_callback.status_handler,
artifacts_handler=self.task.runner_callback.artifacts_handler,
**self.runner_params, **self.runner_params,
) )