From 25cdfad69a1b6f4d4ba8871a333d2c712b75221a Mon Sep 17 00:00:00 2001 From: Kiran K A Date: Thu, 13 Jun 2024 15:28:22 +0530 Subject: [PATCH 1/4] Redis cluster Mode connetion string modification --- .../src/formsflow_api_utils/utils/caching.py | 10 +++++++--- forms-flow-api/requirements.txt | 4 ++-- forms-flow-api/requirements/prod.txt | 2 +- forms-flow-api/sample.env | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py b/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py index 898face689..7bbab23887 100644 --- a/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py +++ b/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py @@ -4,7 +4,8 @@ from flask import current_app from redis.client import Redis import json - +import os +from redis import RedisCluster as rc class RedisManager: """ @@ -28,11 +29,15 @@ def get_client(cls, app=None) -> Redis: Raises: Exception: If the Redis client has not been initialized and no app context is provided. """ + redis_cluster = os.getenv('REDIS_CLUSTER', 'false').lower() == 'true' if cls._redis_client is None: if app is None: app = current_app redis_url = app.config.get("REDIS_URL") - cls._redis_client = redis.StrictRedis.from_url(redis_url) + if redis_cluster: + cls._redis_client = rc.from_url(redis_url) + else: + cls._redis_client = redis.StrictRedis.from_url(redis_url) app.logger.info("Redis client initiated successfully") return cls._redis_client @@ -75,4 +80,3 @@ def get(cls, key): return json.loads(val_json) # Deserialize the JSON string back into Python object else: return None - diff --git a/forms-flow-api/requirements.txt b/forms-flow-api/requirements.txt index ad963d8f18..eeb321b6d9 100644 --- a/forms-flow-api/requirements.txt +++ b/forms-flow-api/requirements.txt @@ -27,7 +27,7 @@ ecdsa==0.18.0 flask-jwt-oidc==0.3.0 flask-marshmallow==1.2.1 flask-restx==1.3.0 -formsflow_api_utils @ git+https://github.com/AOT-Technologies/forms-flow-ai.git@develop#subdirectory=forms-flow-api-utils +formsflow_api_utils @ git+https://github.com/kiran-aot/forms-flow-ai.git@develop#subdirectory=forms-flow-api-utils gunicorn==21.2.0 h11==0.14.0 h2==4.1.0 @@ -51,7 +51,7 @@ pyparsing==3.1.2 python-dotenv==1.0.1 python-jose==3.3.0 pytz==2024.1 -redis==5.0.3 +redis==5.0.5 referencing==0.34.0 requests==2.31.0 rpds-py==0.18.0 diff --git a/forms-flow-api/requirements/prod.txt b/forms-flow-api/requirements/prod.txt index f64f617eb7..c6611527ba 100644 --- a/forms-flow-api/requirements/prod.txt +++ b/forms-flow-api/requirements/prod.txt @@ -16,4 +16,4 @@ sqlalchemy_utils markupsafe PyJWT redis -git+https://github.com/AOT-Technologies/forms-flow-ai.git@develop#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils +git+https://github.com/kiran-aot/forms-flow-ai.git@develop#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils diff --git a/forms-flow-api/sample.env b/forms-flow-api/sample.env index 2b24a5a510..e27cdb90b0 100644 --- a/forms-flow-api/sample.env +++ b/forms-flow-api/sample.env @@ -69,4 +69,5 @@ FORMIO_ROOT_PASSWORD=changeme #CONFIGURE_LOGS=true #Redis configuration -REDIS_URL=redis://{your-ip-address}:6379/0 \ No newline at end of file +REDIS_URL=redis://{your-ip-address}:6379/0 +REDIS_CLUSTER=false \ No newline at end of file From 4504c96c11059372d0affc444eed523d06b1a1e0 Mon Sep 17 00:00:00 2001 From: Kiran K A Date: Fri, 14 Jun 2024 14:44:14 +0530 Subject: [PATCH 2/4] Updated redis connection string to access cluster mode and single node redis --- forms-flow-api/requirements.txt | 2 +- forms-flow-api/requirements/prod.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forms-flow-api/requirements.txt b/forms-flow-api/requirements.txt index eeb321b6d9..32f168eccd 100644 --- a/forms-flow-api/requirements.txt +++ b/forms-flow-api/requirements.txt @@ -27,7 +27,7 @@ ecdsa==0.18.0 flask-jwt-oidc==0.3.0 flask-marshmallow==1.2.1 flask-restx==1.3.0 -formsflow_api_utils @ git+https://github.com/kiran-aot/forms-flow-ai.git@develop#subdirectory=forms-flow-api-utils +formsflow_api_utils @ git+https://github.com/AOT-Technologies/forms-flow-ai.git@develop#subdirectory=forms-flow-api-utils gunicorn==21.2.0 h11==0.14.0 h2==4.1.0 diff --git a/forms-flow-api/requirements/prod.txt b/forms-flow-api/requirements/prod.txt index c6611527ba..f64f617eb7 100644 --- a/forms-flow-api/requirements/prod.txt +++ b/forms-flow-api/requirements/prod.txt @@ -16,4 +16,4 @@ sqlalchemy_utils markupsafe PyJWT redis -git+https://github.com/kiran-aot/forms-flow-ai.git@develop#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils +git+https://github.com/AOT-Technologies/forms-flow-ai.git@develop#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils From 1eb6332ad2f30c7a8c67f2263c01b8c83bf2077e Mon Sep 17 00:00:00 2001 From: Kiran K A Date: Tue, 9 Jul 2024 10:38:10 +0530 Subject: [PATCH 3/4] keycloak environment varibales updated for latest version --- forms-flow-idm/keycloak/docker-compose.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/forms-flow-idm/keycloak/docker-compose.yml b/forms-flow-idm/keycloak/docker-compose.yml index df21043fab..48ec64c2c9 100644 --- a/forms-flow-idm/keycloak/docker-compose.yml +++ b/forms-flow-idm/keycloak/docker-compose.yml @@ -21,7 +21,7 @@ services: POSTGRES_USER: ${KEYCLOAK_JDBC_USER:-admin} POSTGRES_PASSWORD: ${KEYCLOAK_JDBC_PASSWORD:-changeme} ports: - - 5431:5431 + - 5431:5432 networks: - keycloak-server-network @@ -33,12 +33,13 @@ services: - keycloak_custom_data:/keycloak_custom_data entrypoint: ["/bin/bash", "-c", "/keycloak_custom_data/start-keycloak.sh"] environment: - - DB_VENDOR=POSTGRES - - DB_ADDR=keycloak-db - - DB_PORT=5432 - - DB_DATABASE=${KEYCLOAK_JDBC_DB:-keycloak} - - DB_USER=${KEYCLOAK_JDBC_USER:-admin} - - DB_PASSWORD=${KEYCLOAK_JDBC_PASSWORD:-changeme} + - KC_DB=postgres + - KC_DB_URL_HOST=keycloak-db + - KC_DB_URL_PORT=5432 + - KC_DB_URL_DATABASE=${KEYCLOAK_JDBC_DB:-keycloak} + - KC_DB_USERNAME=${KEYCLOAK_JDBC_USER:-admin} + - KC_DB_PASSWORD=${KEYCLOAK_JDBC_PASSWORD:-changeme} + - KC_DB_URL=jdbc:postgresql://keycloak-db/keycloak - KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN_USER:-admin} - KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-changeme} - KEYCLOAK_START_MODE=${KEYCLOAK_START_MODE:-start-dev} From 84737552a93659fc8cc7ff0454a8f9324c8f21bc Mon Sep 17 00:00:00 2001 From: Kiran K A Date: Tue, 9 Jul 2024 10:40:57 +0530 Subject: [PATCH 4/4] Update docker-compose.yml --- forms-flow-idm/keycloak/docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/forms-flow-idm/keycloak/docker-compose.yml b/forms-flow-idm/keycloak/docker-compose.yml index 48ec64c2c9..c50b1b7772 100644 --- a/forms-flow-idm/keycloak/docker-compose.yml +++ b/forms-flow-idm/keycloak/docker-compose.yml @@ -39,7 +39,6 @@ services: - KC_DB_URL_DATABASE=${KEYCLOAK_JDBC_DB:-keycloak} - KC_DB_USERNAME=${KEYCLOAK_JDBC_USER:-admin} - KC_DB_PASSWORD=${KEYCLOAK_JDBC_PASSWORD:-changeme} - - KC_DB_URL=jdbc:postgresql://keycloak-db/keycloak - KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN_USER:-admin} - KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-changeme} - KEYCLOAK_START_MODE=${KEYCLOAK_START_MODE:-start-dev}