From d4a58c706b44609d77b49144d6550765bffd6f5b Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Tue, 19 Apr 2022 14:56:10 +0100 Subject: [PATCH 1/2] bind to notify-redis automatically this ensures that if we create a new version of the app, it'll connect to redis properly (for example a UR prototype) --- manifest.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yml.j2 b/manifest.yml.j2 index 17ee2f658..cceff3ee5 100644 --- a/manifest.yml.j2 +++ b/manifest.yml.j2 @@ -33,6 +33,7 @@ applications: - logit-ssl-syslog-drain - notify-prometheus - notify-splunk + - notify-redis env: NOTIFY_APP_NAME: admin @@ -61,6 +62,5 @@ applications: TEMPLATE_PREVIEW_API_KEY: '{{ TEMPLATE_PREVIEW_API_KEY }}' REDIS_ENABLED: '{{ REDIS_ENABLED }}' - REDIS_URL: '{{ REDIS_URL }}' NOTIFY_BILLING_DETAILS: '{{ NOTIFY_BILLING_DETAILS | tojson }}' From 4a3ba971153e12f0016360bce2b5dbdb4eb1ee22 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Wed, 20 Apr 2022 11:10:12 +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 [1]. [1]: https://github.com/alphagov/notifications-admin/pull/4213 --- app/cloudfoundry_config.py | 5 +---- tests/app/test_cloudfoundry_config.py | 8 -------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/app/cloudfoundry_config.py b/app/cloudfoundry_config.py index d3ed47170..917ef4297 100644 --- a/app/cloudfoundry_config.py +++ b/app/cloudfoundry_config.py @@ -4,7 +4,4 @@ import os def extract_cloudfoundry_config(): vcap_services = json.loads(os.environ['VCAP_SERVICES']) - - # 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 06f02de5d..3aeada404 100644 --- a/tests/app/test_cloudfoundry_config.py +++ b/tests/app/test_cloudfoundry_config.py @@ -22,11 +22,3 @@ def test_extract_cloudfoundry_config_populates_other_vars(os_environ, vcap_servi extract_cloudfoundry_config() 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