From c9e3873a28064620c2439b7a2dfacf4289779612 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Tue, 1 Mar 2022 10:18:41 -0500 Subject: [PATCH] Use update_fields for Ansible facts update --- awx/main/models/jobs.py | 2 +- awx/main/tests/unit/models/test_jobs.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index fa313dfc2342..9c68b23c4a99 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -846,7 +846,7 @@ def finish_job_fact_cache(self, destination, modification_times): continue host.ansible_facts = ansible_facts host.ansible_facts_modified = now() - host.save() + host.save(update_fields=['ansible_facts', 'ansible_facts_modified']) system_tracking_logger.info( 'New fact for inventory {} host {}'.format(smart_str(host.inventory.name), smart_str(host.name)), extra=dict( diff --git a/awx/main/tests/unit/models/test_jobs.py b/awx/main/tests/unit/models/test_jobs.py index b9e803ec6516..98ac4e21d63e 100644 --- a/awx/main/tests/unit/models/test_jobs.py +++ b/awx/main/tests/unit/models/test_jobs.py @@ -90,7 +90,7 @@ def test_finish_job_fact_cache_with_existing_data(job, hosts, inventory, mocker, assert host.ansible_facts == {"a": 1, "b": 2} assert host.ansible_facts_modified is None assert hosts[1].ansible_facts == ansible_facts_new - hosts[1].save.assert_called_once_with() + hosts[1].save.assert_called_once_with(update_fields=['ansible_facts', 'ansible_facts_modified']) def test_finish_job_fact_cache_with_bad_data(job, hosts, inventory, mocker, tmpdir):