From f95b8b589b46205be3bc670e668e7d2d400e4a49 Mon Sep 17 00:00:00 2001 From: Bastian Hofmann Date: Thu, 27 Jun 2019 00:01:20 +0200 Subject: [PATCH] [stable/redis-ha] Improve liveness probe for large databases (#14999) * [stable/redis-ha] Improve liveness probe so that redis is not restarted while it is still loading its dataset into memory On larger databases this can take more than just the initial probe delay. During this time redis will not answer the ping command with pong, but with loading. Of course the container should not be marked as ready, but it also should not restart which results in redis never starting successfully. Signed-off-by: Bastian Hofmann * [stable/redis-ha] Bump version to 3.5.2 Signed-off-by: Bastian Hofmann --- stable/redis-ha/Chart.yaml | 2 +- stable/redis-ha/templates/redis-ha-healthchecks.yaml | 10 ++++++++++ stable/redis-ha/templates/redis-ha-statefulset.yaml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/stable/redis-ha/Chart.yaml b/stable/redis-ha/Chart.yaml index 039aa42b59..722370061d 100644 --- a/stable/redis-ha/Chart.yaml +++ b/stable/redis-ha/Chart.yaml @@ -6,7 +6,7 @@ keywords: - redis - keyvalue - database -version: 3.5.1 +version: 3.5.2 appVersion: 5.0.3 description: Highly available Kubernetes implementation of Redis icon: https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/Redis_Logo.svg/1200px-Redis_Logo.svg.png diff --git a/stable/redis-ha/templates/redis-ha-healthchecks.yaml b/stable/redis-ha/templates/redis-ha-healthchecks.yaml index bef98ae37b..53c78f2afe 100644 --- a/stable/redis-ha/templates/redis-ha-healthchecks.yaml +++ b/stable/redis-ha/templates/redis-ha-healthchecks.yaml @@ -39,3 +39,13 @@ data: echo "Server check failed with: $CHECK_SERVER" exit 1 fi + + liveness.sh: | + #!/bin/sh + set -eu + CHECK_SERVER="$(redis-cli -p "$1"{{ if .Values.auth }} -a "$AUTH"{{ end }} ping)" + + if [ "$CHECK_SERVER" != "PONG" ] && [ "$CHECK_SERVER" != "LOADING Redis is loading the dataset in memory" ]; then + echo "Server check failed with: $CHECK_SERVER" + exit 1 + fi diff --git a/stable/redis-ha/templates/redis-ha-statefulset.yaml b/stable/redis-ha/templates/redis-ha-statefulset.yaml index dd87b0501f..a5facd2918 100644 --- a/stable/redis-ha/templates/redis-ha-statefulset.yaml +++ b/stable/redis-ha/templates/redis-ha-statefulset.yaml @@ -136,7 +136,7 @@ spec: {{- end }} livenessProbe: exec: - command: [ "sh", "/probes/readiness.sh", "{{ .Values.redis.port }}"] + command: [ "sh", "/probes/liveness.sh", "{{ .Values.redis.port }}"] initialDelaySeconds: 15 periodSeconds: 5 readinessProbe: