diff --git a/awx/main/management/commands/cleanup_jobs.py b/awx/main/management/commands/cleanup_jobs.py index 81f405da4c..511072834a 100644 --- a/awx/main/management/commands/cleanup_jobs.py +++ b/awx/main/management/commands/cleanup_jobs.py @@ -16,13 +16,10 @@ from awx.main.models import ( Job, AdHocCommand, ProjectUpdate, InventoryUpdate, SystemJob, WorkflowJob, Notification ) -from awx.main.signals import ( # noqa - emit_update_inventory_on_created_or_deleted, - emit_update_inventory_computed_fields, +from awx.main.signals import ( disable_activity_stream, disable_computed_fields ) -from django.db.models.signals import post_save, post_delete, m2m_changed # noqa class Command(BaseCommand): diff --git a/awx/main/migrations/0106_v370_remove_inventory_groups_with_active_failures.py b/awx/main/migrations/0106_v370_remove_inventory_groups_with_active_failures.py new file mode 100644 index 0000000000..bc210e9fd3 --- /dev/null +++ b/awx/main/migrations/0106_v370_remove_inventory_groups_with_active_failures.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.8 on 2020-01-27 12:39 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0105_v370_remove_jobevent_parent_and_hosts'), + ] + + operations = [ + migrations.RemoveField( + model_name='inventory', + name='groups_with_active_failures', + ), + ] diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index aa0a569dbb..9ced56cc4a 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -122,12 +122,6 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin, RelatedJobsMixin): help_text=_('This field is deprecated and will be removed in a future release. ' 'Total number of groups in this inventory.'), ) - groups_with_active_failures = models.PositiveIntegerField( - default=0, - editable=False, - help_text=_('This field is deprecated and will be removed in a future release. ' - 'Number of groups in this inventory with active failures.'), - ) has_inventory_sources = models.BooleanField( default=False, editable=False, diff --git a/awx/main/models/notifications.py b/awx/main/models/notifications.py index 26ff15580f..71a68b2a9f 100644 --- a/awx/main/models/notifications.py +++ b/awx/main/models/notifications.py @@ -274,7 +274,7 @@ class JobNotificationMixin(object): {'playbook_counts': ['play_count', 'task_count']}, {'summary_fields': [{'inventory': ['id', 'name', 'description', 'has_active_failures', 'total_hosts', 'hosts_with_active_failures', 'total_groups', - 'groups_with_active_failures', 'has_inventory_sources', + 'has_inventory_sources', 'total_inventory_sources', 'inventory_sources_with_failures', 'organization_id', 'kind']}, {'project': ['id', 'name', 'description', 'status', 'scm_type']}, @@ -327,7 +327,6 @@ class JobNotificationMixin(object): 'username': 'admin'}, 'instance_group': {'id': 1, 'name': 'tower'}, 'inventory': {'description': 'Sample inventory description', - 'groups_with_active_failures': 0, 'has_active_failures': False, 'has_inventory_sources': False, 'hosts_with_active_failures': 0, diff --git a/awx/main/signals.py b/awx/main/signals.py index 185033649f..bc39fa85d0 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -72,41 +72,6 @@ def get_current_user_or_none(): return u -def emit_update_inventory_computed_fields(sender, **kwargs): - logger.debug("In update inventory computed fields") - if getattr(_inventory_updates, 'is_updating', False): - return - instance = kwargs['instance'] - if sender == Group.hosts.through: - sender_name = 'group.hosts' - elif sender == Group.parents.through: - sender_name = 'group.parents' - elif sender == Host.inventory_sources.through: - sender_name = 'host.inventory_sources' - elif sender == Group.inventory_sources.through: - sender_name = 'group.inventory_sources' - else: - sender_name = str(sender._meta.verbose_name) - if kwargs['signal'] == post_save: - if sender == Job: - return - sender_action = 'saved' - elif kwargs['signal'] == post_delete: - sender_action = 'deleted' - elif kwargs['signal'] == m2m_changed and kwargs['action'] in ('post_add', 'post_remove', 'post_clear'): - sender_action = 'changed' - else: - return - logger.debug('%s %s, updating inventory computed fields: %r %r', - sender_name, sender_action, sender, kwargs) - try: - inventory = instance.inventory - except Inventory.DoesNotExist: - pass - else: - update_inventory_computed_fields.delay(inventory.id) - - def emit_update_inventory_on_created_or_deleted(sender, **kwargs): if getattr(_inventory_updates, 'is_updating', False): return @@ -210,10 +175,6 @@ def connect_computed_field_signals(): post_delete.connect(emit_update_inventory_on_created_or_deleted, sender=Host) post_save.connect(emit_update_inventory_on_created_or_deleted, sender=Group) post_delete.connect(emit_update_inventory_on_created_or_deleted, sender=Group) - m2m_changed.connect(emit_update_inventory_computed_fields, sender=Group.hosts.through) - m2m_changed.connect(emit_update_inventory_computed_fields, sender=Group.parents.through) - m2m_changed.connect(emit_update_inventory_computed_fields, sender=Host.inventory_sources.through) - m2m_changed.connect(emit_update_inventory_computed_fields, sender=Group.inventory_sources.through) post_save.connect(emit_update_inventory_on_created_or_deleted, sender=InventorySource) post_delete.connect(emit_update_inventory_on_created_or_deleted, sender=InventorySource) post_save.connect(emit_update_inventory_on_created_or_deleted, sender=Job) @@ -350,10 +311,6 @@ def disable_computed_fields(): post_delete.disconnect(emit_update_inventory_on_created_or_deleted, sender=Host) post_save.disconnect(emit_update_inventory_on_created_or_deleted, sender=Group) post_delete.disconnect(emit_update_inventory_on_created_or_deleted, sender=Group) - m2m_changed.disconnect(emit_update_inventory_computed_fields, sender=Group.hosts.through) - m2m_changed.disconnect(emit_update_inventory_computed_fields, sender=Group.parents.through) - m2m_changed.disconnect(emit_update_inventory_computed_fields, sender=Host.inventory_sources.through) - m2m_changed.disconnect(emit_update_inventory_computed_fields, sender=Group.inventory_sources.through) post_save.disconnect(emit_update_inventory_on_created_or_deleted, sender=InventorySource) post_delete.disconnect(emit_update_inventory_on_created_or_deleted, sender=InventorySource) post_save.disconnect(emit_update_inventory_on_created_or_deleted, sender=Job) diff --git a/awx/main/tests/functional/models/test_notifications.py b/awx/main/tests/functional/models/test_notifications.py index 00cc217a82..02a2b28e83 100644 --- a/awx/main/tests/functional/models/test_notifications.py +++ b/awx/main/tests/functional/models/test_notifications.py @@ -48,7 +48,6 @@ class TestJobNotificationMixin(object): 'username': str}, 'instance_group': {'id': int, 'name': str}, 'inventory': {'description': str, - 'groups_with_active_failures': int, 'has_active_failures': bool, 'has_inventory_sources': bool, 'hosts_with_active_failures': int,