[bitnami/redis] Fix data loss when executing failover (#13021)

* [bitnami/redis] Fix data loss when executing failover

Signed-off-by: Jota Martos <jotamartos@vmware.com>

* [bitnami/redis] Add comment to provide more information regarding the actions that will be executed

Signed-off-by: Jota Martos <jotamartos@vmware.com>

* Update comments in the script

Signed-off-by: jota <jota@bitnami.com>

* Run failover command in the redis server to decrease the service interruption time

Signed-off-by: jotamartos <jotamartos@vmware.com>

* Do not run the client pause command if failover is run

Signed-off-by: jotamartos <jotamartos@vmware.com>

* Use one single node to avoid issues with the resilience-tests

Signed-off-by: jotamartos <jotamartos@vmware.com>

Signed-off-by: Jota Martos <jotamartos@vmware.com>
Signed-off-by: jota <jota@bitnami.com>
Signed-off-by: jotamartos <jotamartos@vmware.com>
This commit is contained in:
Juan José Martos
2022-11-04 13:18:55 +01:00
committed by GitHub
parent ba56caa58f
commit b2c51d6ba5
3 changed files with 18 additions and 5 deletions

View File

@@ -26,7 +26,8 @@
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
"name": "S4"
"name": "S4",
"worker_nodes_instance_count": "1"
}
}
},

View File

@@ -26,7 +26,8 @@
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
"name": "S4"
"name": "S4",
"worker_nodes_instance_count": "1"
}
}
},

View File

@@ -478,7 +478,7 @@ data:
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
redis-cli -h 127.0.0.1 -p "$REDIS_TLS_PORT" --tls --cert "$REDIS_TLS_CERT_FILE" --key "$REDIS_TLS_KEY_FILE" --cacert "$REDIS_TLS_CA_FILE" "$@"
else
redis-cli -h 127.0.0.1 -p ${REDIS_PORT} "$@"
redis-cli -h 127.0.0.1 -p "$REDIS_PORT" "$@"
fi
}
failover_finished() {
@@ -491,8 +491,19 @@ data:
[[ -f "$REDIS_PASSWORD_FILE" ]] && export REDISCLI_AUTH="$(< "${REDIS_PASSWORD_FILE}")"
if ! failover_finished; then
echo "Waiting for sentinel to run failover for up to {{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}s"
retry_while "failover_finished" "{{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}" 1
echo "I am the master pod and you are stopping me."
# Running failover command
echo "Running the FAILOVER command"
run_redis_command FAILOVER TIMEOUT "{{ mul (sub .Values.sentinel.terminationGracePeriodSeconds 10) 1000 }}"
# Waiting for the failover to finish
echo "Waiting for the failover to finish up to {{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}s"
if retry_while "failover_finished" "{{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}" 1
echo "Master has been successfuly failed over to a different pod."
exit 0
else
echo "Master failover failed"
exit 1
fi
else
exit 0
fi