diff --git a/common/djangoapps/entitlements/tasks.py b/common/djangoapps/entitlements/tasks.py index 05b750bd39..02fbeaf326 100644 --- a/common/djangoapps/entitlements/tasks.py +++ b/common/djangoapps/entitlements/tasks.py @@ -19,11 +19,7 @@ LOGGER = get_task_logger(__name__) MAX_RETRIES = 11 -@shared_task( - bind=True, - ignore_result=True, - name='entitlements.expire_old_entitlements', -) +@shared_task(bind=True, ignore_result=True) @set_code_owner_attribute def expire_old_entitlements(self, start, end, logid='...'): """ diff --git a/common/djangoapps/student/tasks.py b/common/djangoapps/student/tasks.py index 00417c2875..f76ece332e 100644 --- a/common/djangoapps/student/tasks.py +++ b/common/djangoapps/student/tasks.py @@ -20,9 +20,13 @@ from openedx.core.lib.celery.task_utils import emulate_http_request log = logging.getLogger('edx.celery.task') -@shared_task(bind=True, name='student.send_activation_email') +# This is a task function that is in the process of being renamed. +# In order to avoid dropping tasks during deployment, we have to register it twice, +# once under each name. This allows us to cut from one name to the other safely. +# Once we have fully switched to the new name, we can go back to registering +# this task function with a simple decorator. @set_code_owner_attribute -def send_activation_email(self, msg_string, from_address=None): +def _send_activation_email(self, msg_string, from_address=None): """ Sending an activation email to the user. """ @@ -67,3 +71,15 @@ def send_activation_email(self, msg_string, from_address=None): dest_addr, ) raise Exception + + +_OLD_TASK_NAME = 'student.send_activation_email' +_NEW_TASK_NAME = 'common.djangoapps.student.tasks.send_activation_email' + + +# Register task under both its old and new names, +# but expose only the old-named task for invocation. +# -> Next step: Once we deploy and teach Celery workers the new name, +# set `send_activation_email` to the new-named task. +send_activation_email = shared_task(bind=True, name=_OLD_TASK_NAME)(_send_activation_email) +shared_task(bind=True, name=_NEW_TASK_NAME)(_send_activation_email) diff --git a/common/djangoapps/third_party_auth/tasks.py b/common/djangoapps/third_party_auth/tasks.py index e38598b31e..fed4579e48 100644 --- a/common/djangoapps/third_party_auth/tasks.py +++ b/common/djangoapps/third_party_auth/tasks.py @@ -31,7 +31,7 @@ class MetadataParseError(Exception): pass -@shared_task(name='third_party_auth.fetch_saml_metadata') +@shared_task @set_code_owner_attribute def fetch_saml_metadata(): """