Skip to content

Commit

Permalink
By default, do not count indirect hosts (#15801)
Browse files Browse the repository at this point in the history
* By default, do not count indirect hosts

* Fix copy paste goof

* Fix linter issue from base branch
  • Loading branch information
AlanCoding authored and pb82 committed Feb 14, 2025
1 parent fb561be commit 472b6c5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion awx/main/migrations/0201_indirect_managed_node_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions awx/main/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions awx/main/tasks/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
10 changes: 4 additions & 6 deletions awx/main/tests/functional/tasks/test_host_indirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand All @@ -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


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 472b6c5

Please sign in to comment.