diff --git a/controlpanel/api/models/app.py b/controlpanel/api/models/app.py index 099860d0a..88359206f 100644 --- a/controlpanel/api/models/app.py +++ b/controlpanel/api/models/app.py @@ -232,9 +232,6 @@ def delete_customer_by_email(self, email, group_id): def status(self): return "Deployed" - def deployment_envs(self, github_token): - return cluster.App(self, github_token).get_deployment_envs() - def delete(self, *args, **kwargs): github_api_token = None if "github_api_token" in kwargs: @@ -319,8 +316,12 @@ class DeleteCustomerError(Exception): @receiver(post_save, sender=App) def trigger_app_create_related_messages(sender, instance, created, **kwargs): - if created: - tasks.AppCreateRole(instance, instance.current_user).create_task() + if not created: + return + tasks.AppCreateRole(instance, instance.current_user).create_task() + + # TODO this could be removed as part of a review of task queue usage + if instance.deployment_envs: tasks.AppCreateAuth(instance, instance.current_user, extra_data=dict( deployment_envs=instance.deployment_envs, disable_authentication=instance.disable_authentication, diff --git a/controlpanel/api/tasks/app.py b/controlpanel/api/tasks/app.py index ba399419d..edf91985f 100644 --- a/controlpanel/api/tasks/app.py +++ b/controlpanel/api/tasks/app.py @@ -33,7 +33,6 @@ def _get_args_list(self): self.extra_data.get('deployment_envs'), self.extra_data.get('disable_authentication'), self.extra_data.get('connections'), - # self.extra_data.get('has_ip_ranges') # NOT USED, REMOVE IT? ] @property diff --git a/tests/api/models/test_app.py b/tests/api/models/test_app.py index f479a1f56..3d81825ff 100644 --- a/tests/api/models/test_app.py +++ b/tests/api/models/test_app.py @@ -50,10 +50,6 @@ def test_create(sqs, helpers): helpers.validate_task_with_sqs_messages( iam_messages, App.__name__, app.id, queue_name=settings.IAM_QUEUE_NAME ) - auth_messages = helpers.retrieve_messages(sqs, queue_name=settings.AUTH_QUEUE_NAME) - helpers.validate_task_with_sqs_messages( - auth_messages, App.__name__, app.id, queue_name=settings.AUTH_QUEUE_NAME - ) @pytest.mark.django_db diff --git a/tests/api/views/test_app.py b/tests/api/views/test_app.py index bb6a50432..aaacdbf94 100644 --- a/tests/api/views/test_app.py +++ b/tests/api/views/test_app.py @@ -173,8 +173,8 @@ def test_create(client, users, sqs, helpers): assert response.data["repo_url"] == "https://example.com/bar" app = App.objects.get(repo_url="https://example.com/bar") - messages = helpers.retrieve_messages(sqs) - helpers.validate_task_with_sqs_messages(messages, App.__name__, app.id) + messages = helpers.retrieve_messages(sqs, queue_name=settings.IAM_QUEUE_NAME) + helpers.validate_task_with_sqs_messages(messages, App.__name__, app.id, queue_name=settings.IAM_QUEUE_NAME) def test_update(client, app):