From 71aba8136db2e963955d68e9fe997d9b7e879073 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 16 Feb 2022 12:33:01 -0300 Subject: [PATCH] Celery: remove duplication of task names This was used to allow new instances to execute old Celery task names since they were moved into different modules and their name changed. --- readthedocs/projects/apps.py | 4 - readthedocs/projects/tasks/__init__.py | 121 ------------------------- 2 files changed, 125 deletions(-) delete mode 100644 readthedocs/projects/tasks/__init__.py diff --git a/readthedocs/projects/apps.py b/readthedocs/projects/apps.py index 1513816ce77..a8cabefab65 100644 --- a/readthedocs/projects/apps.py +++ b/readthedocs/projects/apps.py @@ -8,10 +8,6 @@ class ProjectsConfig(AppConfig): name = 'readthedocs.projects' def ready(self): - # TODO: remove this import after the deploy together with the - # `tasks/__init__.py` file - import readthedocs.projects.tasks - import readthedocs.projects.tasks.builds import readthedocs.projects.tasks.search import readthedocs.projects.tasks.utils diff --git a/readthedocs/projects/tasks/__init__.py b/readthedocs/projects/tasks/__init__.py deleted file mode 100644 index 8850e81569f..00000000000 --- a/readthedocs/projects/tasks/__init__.py +++ /dev/null @@ -1,121 +0,0 @@ -import structlog - -from readthedocs.worker import app - -from .builds import update_docs_task as update_docs_task_new -from .builds import sync_repository_task as sync_repository_task_new -from .search import fileify as fileify_new -from .search import remove_search_indexes as remove_search_indexes_new -from .utils import remove_build_storage_paths as remove_build_storage_paths_new -from .utils import finish_inactive_builds as finish_inactive_builds_new - - -log = structlog.get_logger(__name__) - -# TODO: remove this file completely after deploy. -# -# This file re-defines all the tasks that were moved from -# `readthedocs/projects/task.py` file into -# `readthedocs/projects/tasks/builds.py,search.py,utils.py` to keep the same -# names and be able to attend tasks triggered with the old names by old web -# instances during the deploy. -# -# Besides, if the signature of the task has changed, it alter the way the task -# is called passing the correct arguments - - -@app.task( - bind=True, - max_retries=5, - default_retry_delay=7 * 60, -) -def update_docs_task(self, version_pk, *args, **kwargs): - log.info( - 'Triggering the new `update_docs_task`', - delivery_info=self.request.delivery_info, - ) - - update_docs_task_new.apply_async( - args=[ - version_pk, - kwargs.get('build_pk'), - ], - kwargs={ - 'build_commit': kwargs.get('commit'), - }, - queue=self.request.delivery_info.get('routing_key') - ) - - -@app.task( - max_retries=5, - default_retry_delay=7 * 60, - bind=True, -) -def sync_repository_task(self, version_pk): - sync_repository_task_new.apply_async( - args=[ - version_pk, - ], - kwargs={}, - queue=self.request.delivery_info.get('routing_key') - ) - - -@app.task( - queue='reindex', - bind=True, -) -def fileify(self, version_pk, commit, build, search_ranking, search_ignore): - fileify_new.apply_async( - args=[ - version_pk, - commit, - build, - search_ranking, - search_ignore, - ], - kwargs={}, - queue=self.request.delivery_info.get('routing_key') - ) - - -@app.task( - queue='web', - bind=True, -) -def remove_build_storage_paths(self, paths): - remove_build_storage_paths_new.apply_async( - args=[ - paths, - ], - kwargs={}, - queue=self.request.delivery_info.get('routing_key') - ) - - -@app.task( - queue='web', - bind=True, -) -def remove_search_indexes(self, project_slug, version_slug=None): - remove_search_indexes_new.apply_async( - args=[ - project_slug, - ], - kwargs={ - 'version_slug': version_slug, - }, - queue=self.request.delivery_info.get('routing_key') - ) - - -@app.task( - bind=True, -) -def finish_inactive_builds(self): - finish_inactive_builds_new.apply_async( - args=[], - kwargs={}, - queue=self.request.delivery_info.get('routing_key') - )