From f2e9990eeb0abbba53612decc57d4ce6e663eb63 Mon Sep 17 00:00:00 2001 From: Julien Maupetit Date: Thu, 5 Dec 2019 16:57:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(dogwood/3/fun)=20allow=20CELERY=5F?= =?UTF-8?q?RESULT=5FBACKEND=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CELERY_RESULT_BACKEND was not configurable, and thus cannot be customized for production where we use the database backend. --- releases/dogwood/3/fun/CHANGELOG.md | 1 + .../3/fun/config/cms/docker_run_production.py | 27 ++++++++++++++----- .../3/fun/config/lms/docker_run_production.py | 26 +++++++++++++----- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/releases/dogwood/3/fun/CHANGELOG.md b/releases/dogwood/3/fun/CHANGELOG.md index a7771901..07e82a82 100644 --- a/releases/dogwood/3/fun/CHANGELOG.md +++ b/releases/dogwood/3/fun/CHANGELOG.md @@ -12,6 +12,7 @@ release. ### Changed - Switch ORA2 production backend to Swift +- Make `CELERY_RESULT_BACKEND` configurable ## [dogwood.3-fun-1.3.1] - 2019-12-04 diff --git a/releases/dogwood/3/fun/config/cms/docker_run_production.py b/releases/dogwood/3/fun/config/cms/docker_run_production.py index 69346472..2a843c6c 100644 --- a/releases/dogwood/3/fun/config/cms/docker_run_production.py +++ b/releases/dogwood/3/fun/config/cms/docker_run_production.py @@ -74,7 +74,10 @@ BROKER_CONNECTION_TIMEOUT = 1 # For the Result Store, use the django cache named 'celery' -CELERY_RESULT_BACKEND = "djcelery.backends.cache:CacheBackend" +CELERY_RESULT_BACKEND = config( + "CELERY_RESULT_BACKEND", default="djcelery.backends.cache:CacheBackend" +) + # When the broker is behind an ELB, use a heartbeat to refresh the # connection and to detect if it has been dropped. @@ -178,8 +181,12 @@ SESSION_REDIS_DB = config("SESSION_REDIS_DB", default=1, formatter=int) SESSION_REDIS_PASSWORD = config("SESSION_REDIS_PASSWORD", default=None) SESSION_REDIS_PREFIX = config("SESSION_REDIS_PREFIX", default="session") -SESSION_REDIS_SOCKET_TIMEOUT = config("SESSION_REDIS_SOCKET_TIMEOUT", default=1, formatter=int) -SESSION_REDIS_RETRY_ON_TIMEOUT = config("SESSION_REDIS_RETRY_ON_TIMEOUT", default=False, formatter=bool) +SESSION_REDIS_SOCKET_TIMEOUT = config( + "SESSION_REDIS_SOCKET_TIMEOUT", default=1, formatter=int +) +SESSION_REDIS_RETRY_ON_TIMEOUT = config( + "SESSION_REDIS_RETRY_ON_TIMEOUT", default=False, formatter=bool +) SESSION_REDIS = config( "SESSION_REDIS", @@ -194,8 +201,12 @@ }, formatter=json.loads, ) -SESSION_REDIS_SENTINEL_LIST = config("SESSION_REDIS_SENTINEL_LIST", default=None, formatter=json.loads) -SESSION_REDIS_SENTINEL_MASTER_ALIAS = config("SESSION_REDIS_SENTINEL_MASTER_ALIAS", default=None) +SESSION_REDIS_SENTINEL_LIST = config( + "SESSION_REDIS_SENTINEL_LIST", default=None, formatter=json.loads +) +SESSION_REDIS_SENTINEL_MASTER_ALIAS = config( + "SESSION_REDIS_SENTINEL_MASTER_ALIAS", default=None +) # social sharing settings SOCIAL_SHARING_SETTINGS = config( @@ -489,9 +500,11 @@ port=CELERY_BROKER_PORT, vhost=CELERY_BROKER_VHOST, ) -# To use redis-sentinel, refer to the documenation here +# To use redis-sentinel, refer to the documenation here # https://celery-redis-sentinel.readthedocs.io/en/latest/ -BROKER_TRANSPORT_OPTIONS = config("BROKER_TRANSPORT_OPTIONS", default={}, formatter=json.loads) +BROKER_TRANSPORT_OPTIONS = config( + "BROKER_TRANSPORT_OPTIONS", default={}, formatter=json.loads +) # Event tracking TRACKING_BACKENDS.update(config("TRACKING_BACKENDS", default={}, formatter=json.loads)) diff --git a/releases/dogwood/3/fun/config/lms/docker_run_production.py b/releases/dogwood/3/fun/config/lms/docker_run_production.py index 7a599646..d9e39170 100644 --- a/releases/dogwood/3/fun/config/lms/docker_run_production.py +++ b/releases/dogwood/3/fun/config/lms/docker_run_production.py @@ -83,7 +83,9 @@ BROKER_CONNECTION_TIMEOUT = 1 # For the Result Store, use the django cache named 'celery' -CELERY_RESULT_BACKEND = "djcelery.backends.cache:CacheBackend" +CELERY_RESULT_BACKEND = config( + "CELERY_RESULT_BACKEND", default="djcelery.backends.cache:CacheBackend" +) # When the broker is behind an ELB, use a heartbeat to refresh the # connection and to detect if it has been dropped. @@ -189,8 +191,12 @@ SESSION_REDIS_DB = config("SESSION_REDIS_DB", default=1, formatter=int) SESSION_REDIS_PASSWORD = config("SESSION_REDIS_PASSWORD", default=None) SESSION_REDIS_PREFIX = config("SESSION_REDIS_PREFIX", default="session") -SESSION_REDIS_SOCKET_TIMEOUT = config("SESSION_REDIS_SOCKET_TIMEOUT", default=1, formatter=int) -SESSION_REDIS_RETRY_ON_TIMEOUT = config("SESSION_REDIS_RETRY_ON_TIMEOUT", default=False, formatter=bool) +SESSION_REDIS_SOCKET_TIMEOUT = config( + "SESSION_REDIS_SOCKET_TIMEOUT", default=1, formatter=int +) +SESSION_REDIS_RETRY_ON_TIMEOUT = config( + "SESSION_REDIS_RETRY_ON_TIMEOUT", default=False, formatter=bool +) SESSION_REDIS = config( "SESSION_REDIS", @@ -205,8 +211,12 @@ }, formatter=json.loads, ) -SESSION_REDIS_SENTINEL_LIST = config("SESSION_REDIS_SENTINEL_LIST", default=None, formatter=json.loads) -SESSION_REDIS_SENTINEL_MASTER_ALIAS = config("SESSION_REDIS_SENTINEL_MASTER_ALIAS", default=None) +SESSION_REDIS_SENTINEL_LIST = config( + "SESSION_REDIS_SENTINEL_LIST", default=None, formatter=json.loads +) +SESSION_REDIS_SENTINEL_MASTER_ALIAS = config( + "SESSION_REDIS_SENTINEL_MASTER_ALIAS", default=None +) REGISTRATION_EXTRA_FIELDS = config( "REGISTRATION_EXTRA_FIELDS", default=REGISTRATION_EXTRA_FIELDS, formatter=json.loads @@ -741,9 +751,11 @@ port=CELERY_BROKER_PORT, vhost=CELERY_BROKER_VHOST, ) -# To use redis-sentinel, refer to the documenation here +# To use redis-sentinel, refer to the documenation here # https://celery-redis-sentinel.readthedocs.io/en/latest/ -BROKER_TRANSPORT_OPTIONS = config("BROKER_TRANSPORT_OPTIONS", default={}, formatter=json.loads) +BROKER_TRANSPORT_OPTIONS = config( + "BROKER_TRANSPORT_OPTIONS", default={}, formatter=json.loads +) # upload limits STUDENT_FILEUPLOAD_MAX_SIZE = config(