Skip to content

Commit

Permalink
AAP-14538 Only process ansible_facts for successful jobs (ansible#14313)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding authored Aug 4, 2023
1 parent abc5630 commit 6f9ea18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions awx/main/tasks/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, model=None):
self.model = model
self.update_attempts = int(settings.DISPATCHER_DB_DOWNTOWN_TOLLERANCE / 5)
self.wrapup_event_dispatched = False
self.artifacts_processed = False
self.extra_update_fields = {}

def update_model(self, pk, _attempt=0, **updates):
Expand Down Expand Up @@ -211,6 +212,9 @@ def status_handler(self, status_data, runner_config):
if result_traceback:
self.delay_update(result_traceback=result_traceback)

def artifacts_handler(self, artifact_dir):
self.artifacts_processed = True


class RunnerCallbackForProjectUpdate(RunnerCallback):
def __init__(self, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tasks/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ def post_run_hook(self, job, status):
# actual `run()` call; this _usually_ means something failed in
# the pre_run_hook method
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")
finish_fact_cache(
job.get_hosts_for_fact_cache(),
Expand Down
1 change: 1 addition & 0 deletions awx/main/tasks/receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ def processor(self, resultfile):
event_handler=self.task.runner_callback.event_handler,
finished_callback=self.task.runner_callback.finished_callback,
status_handler=self.task.runner_callback.status_handler,
artifacts_handler=self.task.runner_callback.artifacts_handler,
**self.runner_params,
)

Expand Down

0 comments on commit 6f9ea18

Please sign in to comment.