From eb7326068a3bf1a87d33118c6ea83e6b05869392 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Wed, 9 Aug 2023 00:12:39 +0800 Subject: [PATCH] Chore/fix redis rdb policy logic (#37523) * chore/fix-REDIS_RDB_POLICY-logic Signed-off-by: Tony Lee * add for 7,0 Signed-off-by: Tony Lee * add disabled option Signed-off-by: Tony Lee * add space Signed-off-by: Tony Lee * add space Signed-off-by: Tony Lee * Add env var REDIS_RDB_POLICY_DISABLED Signed-off-by: Tony Lee --------- Signed-off-by: Tony Lee --- .../rootfs/opt/bitnami/scripts/libredis.sh | 14 ++++++++------ .../rootfs/opt/bitnami/scripts/libredis.sh | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/libredis.sh b/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/libredis.sh index caa469e9b164..09ad07460a17 100644 --- a/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/libredis.sh +++ b/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/libredis.sh @@ -57,7 +57,7 @@ redis_conf_set() { [[ "$value" = "" ]] && value="\"$value\"" # Determine whether to enable the configuration for RDB persistence, if yes, do not enable the replacement operation - if [ "${key}" == "save" ];then + if [ "${key}" == "save" ]; then echo "${key} ${value}" >> "${REDIS_BASE_DIR}/etc/redis.conf" else replace_in_file "${REDIS_BASE_DIR}/etc/redis.conf" "^#*\s*${key} .*" "${key} ${value}" false @@ -408,12 +408,14 @@ redis_configure_default() { redis_conf_set appendonly "${REDIS_AOF_ENABLED}" #The value stored in $i here is the number of seconds and times of save rules in redis rdb mode - if [ -z "${REDIS_RDB_POLICY}" ];then - redis_conf_set save "" + if is_empty_value "$REDIS_RDB_POLICY"; then + if is_boolean_yes "$REDIS_RDB_POLICY_DISABLED"; then + redis_conf_set save "" + fi else - for i in ${REDIS_RDB_POLICY};do - redis_conf_set save "${i//#/ }" - done + for i in ${REDIS_RDB_POLICY}; do + redis_conf_set save "${i//#/ }" + done fi redis_conf_set port "$REDIS_PORT_NUMBER" diff --git a/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/libredis.sh b/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/libredis.sh index caa469e9b164..09ad07460a17 100644 --- a/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/libredis.sh +++ b/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/libredis.sh @@ -57,7 +57,7 @@ redis_conf_set() { [[ "$value" = "" ]] && value="\"$value\"" # Determine whether to enable the configuration for RDB persistence, if yes, do not enable the replacement operation - if [ "${key}" == "save" ];then + if [ "${key}" == "save" ]; then echo "${key} ${value}" >> "${REDIS_BASE_DIR}/etc/redis.conf" else replace_in_file "${REDIS_BASE_DIR}/etc/redis.conf" "^#*\s*${key} .*" "${key} ${value}" false @@ -408,12 +408,14 @@ redis_configure_default() { redis_conf_set appendonly "${REDIS_AOF_ENABLED}" #The value stored in $i here is the number of seconds and times of save rules in redis rdb mode - if [ -z "${REDIS_RDB_POLICY}" ];then - redis_conf_set save "" + if is_empty_value "$REDIS_RDB_POLICY"; then + if is_boolean_yes "$REDIS_RDB_POLICY_DISABLED"; then + redis_conf_set save "" + fi else - for i in ${REDIS_RDB_POLICY};do - redis_conf_set save "${i//#/ }" - done + for i in ${REDIS_RDB_POLICY}; do + redis_conf_set save "${i//#/ }" + done fi redis_conf_set port "$REDIS_PORT_NUMBER"