From bf083b28aac77dd4b006a5ed5240e98d9cf369da Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Tue, 19 Apr 2022 14:54:10 +0100 Subject: [PATCH 1/2] bind to notify-redis automatically this ensures all apps are bound to redis (for example any new worker types) --- manifest.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yml.j2 b/manifest.yml.j2 index 0d7788880..0f67b7ade 100644 --- a/manifest.yml.j2 +++ b/manifest.yml.j2 @@ -99,6 +99,7 @@ applications: services: - notify-db + - notify-redis - logit-ssl-syslog-drain {% if CF_APP == 'notify-api' %} - notify-prometheus @@ -144,7 +145,6 @@ applications: FIRETEXT_INBOUND_SMS_AUTH: '{{ FIRETEXT_INBOUND_SMS_AUTH | tojson }}' REDIS_ENABLED: '{{ REDIS_ENABLED }}' - REDIS_URL: '{{ REDIS_URL }}' TEMPLATE_PREVIEW_API_HOST: '{{ TEMPLATE_PREVIEW_API_HOST }}' TEMPLATE_PREVIEW_API_KEY: '{{ TEMPLATE_PREVIEW_API_KEY }}' From 0457850fc0ea409451a90b6b078c33b48c5121b3 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 20 Apr 2022 11:41:33 +0100 Subject: [PATCH 2/2] Remove redundant conditional for CF Redis This is now used in all environments and we've removed support for non-CF Redis. --- app/cloudfoundry_config.py | 3 +-- tests/app/test_cloudfoundry_config.py | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/app/cloudfoundry_config.py b/app/cloudfoundry_config.py index de10592a1..d81d3b963 100644 --- a/app/cloudfoundry_config.py +++ b/app/cloudfoundry_config.py @@ -9,5 +9,4 @@ def extract_cloudfoundry_config(): os.environ['SQLALCHEMY_DATABASE_URI'] = vcap_services['postgres'][0]['credentials']['uri'].replace('postgres', 'postgresql') # Redis config - if 'redis' in vcap_services: - os.environ['REDIS_URL'] = vcap_services['redis'][0]['credentials']['uri'] + os.environ['REDIS_URL'] = vcap_services['redis'][0]['credentials']['uri'] diff --git a/tests/app/test_cloudfoundry_config.py b/tests/app/test_cloudfoundry_config.py index b31882541..4a1d6e5e2 100644 --- a/tests/app/test_cloudfoundry_config.py +++ b/tests/app/test_cloudfoundry_config.py @@ -29,11 +29,3 @@ def test_extract_cloudfoundry_config_populates_other_vars(os_environ, vcap_servi assert os.environ['SQLALCHEMY_DATABASE_URI'] == 'postgresql uri' assert os.environ['REDIS_URL'] == 'redis uri' - - -def test_extract_cloudfoundry_config_copes_if_redis_not_set(os_environ, vcap_services): - del vcap_services['redis'] - os.environ['VCAP_SERVICES'] = json.dumps(vcap_services) - - extract_cloudfoundry_config() - assert 'REDIS_URL' not in os.environ