diff --git a/awx/main/migrations/0201_indirect_managed_node_audit.py b/awx/main/migrations/0201_indirect_managed_node_audit.py index b4ce65f052a6..c6d92566937a 100644 --- a/awx/main/migrations/0201_indirect_managed_node_audit.py +++ b/awx/main/migrations/0201_indirect_managed_node_audit.py @@ -14,7 +14,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='job', name='event_queries_processed', - field=models.BooleanField(default=False, help_text='Events of this job have been queried for indirect host information'), + field=models.BooleanField(default=True, help_text='Events of this job have been queried for indirect host information, or do not need processing.'), ), migrations.CreateModel( name='EventQuery', diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 50257fc6075f..c6b8b0988301 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -608,8 +608,8 @@ class Meta: help_text=_("If ran as part of sliced jobs, the total number of slices. If 1, job is not part of a sliced job."), ) event_queries_processed = models.BooleanField( - default=False, - help_text=_("Events of this job have been queried for indirect host information"), + default=True, + help_text=_("Events of this job have been queried for indirect host information, or do not need processing."), ) def _get_parent_field_name(self): diff --git a/awx/main/tasks/callback.py b/awx/main/tasks/callback.py index f07899dd6ca0..c6d89d0b796e 100644 --- a/awx/main/tasks/callback.py +++ b/awx/main/tasks/callback.py @@ -277,6 +277,7 @@ def status_handler(self, status_data, runner_config): def artifacts_handler(self, artifact_dir): success, query_file_contents = try_load_query_file(artifact_dir) if success: + self.delay_update(event_queries_processed=False) collections_info = collect_queries(query_file_contents) for collection, data in collections_info.items(): version = data['version'] diff --git a/awx/main/tests/functional/tasks/test_host_indirect.py b/awx/main/tests/functional/tasks/test_host_indirect.py index 6ac8e409944e..cca85c38f164 100644 --- a/awx/main/tests/functional/tasks/test_host_indirect.py +++ b/awx/main/tests/functional/tasks/test_host_indirect.py @@ -13,7 +13,6 @@ ) from awx.main.models.event_query import EventQuery from awx.main.models.indirect_managed_node_audit import IndirectManagedNodeAudit -from awx.main.tests.functional.conftest import organization """These are unit tests, similar to test_indirect_host_counting in the live tests""" @@ -25,7 +24,8 @@ def bare_job(job_factory): job = job_factory() job.installed_collections = {'demo.query': {'version': '1.0.1'}, 'demo2.query': {'version': '1.0.1'}} - job.save(update_fields=['installed_collections']) + job.event_queries_processed = False + job.save(update_fields=['installed_collections', 'event_queries_processed']) return job @@ -72,11 +72,9 @@ def new_audit_record(bare_job, organization): @pytest.mark.django_db -def test_build_with_no_results(job_factory): +def test_build_with_no_results(bare_job): # never filled in events, should do nothing - job = job_factory() - assert job.event_queries_processed is False - assert build_indirect_host_data(job, {}) == [] + assert build_indirect_host_data(bare_job, {}) == [] @pytest.mark.django_db