Skip to content

Commit

Permalink
Merge pull request ansible#11833 from AlanCoding/facts_update_fields
Browse files Browse the repository at this point in the history
Use update_fields for Ansible facts update
  • Loading branch information
AlanCoding authored Aug 18, 2022
2 parents d87bb97 + c9e3873 commit 532aa83
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion awx/main/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,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(
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tests/unit/models/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 532aa83

Please sign in to comment.