[stable/rabbitmq] enhance readiness-probe to handle pod restart (#14926)

* [stable/rabbitmq] enhance readiness-probe to allow rabbitmq sync data after pod restart
Signed-off-by: aggiefly <aggie_fly@hotmail.com>

* [[stable/rabbitmq] enhance readiness-probe to allow rabbitmq sync data after restart

Signed-off-by: aggiefly <aggie_fly@hotmail.com>
This commit is contained in:
aggiefly
2019-07-01 23:45:08 -07:00
committed by Kubernetes Prow Robot
parent cd2f373d61
commit d97034e526
2 changed files with 21 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
apiVersion: v1
name: rabbitmq
version: 6.1.3
version: 6.1.4
appVersion: 3.7.15
description: Open source message broker software that implements the Advanced Message Queuing Protocol (AMQP)
keywords:
+20 -2
View File
@@ -81,6 +81,7 @@ spec:
- |
mkdir -p /opt/bitnami/rabbitmq/.rabbitmq/
mkdir -p /opt/bitnami/rabbitmq/etc/rabbitmq/
touch /opt/bitnami/rabbitmq/var/lib/rabbitmq/.start
#persist the erlang cookie in both places for server and cli tools
echo $RABBITMQ_ERL_COOKIE > /opt/bitnami/rabbitmq/var/lib/rabbitmq/.erlang.cookie
cp /opt/bitnami/rabbitmq/var/lib/rabbitmq/.erlang.cookie /opt/bitnami/rabbitmq/.rabbitmq/
@@ -105,6 +106,23 @@ spec:
test "\${EXPECTED}" = "\${ACTUAL}"
EOF
chmod a+x /opt/bitnami/rabbitmq/sbin/rabbitmq-api-check
#health check for probes, handle period during rabbtmq sync
cat > /opt/bitnami/rabbitmq/sbin/rabbitmq-health-check <<EOF
#!/bin/sh
START_FLAG=/opt/bitnami/rabbitmq/var/lib/rabbitmq/.start
if [ -f \${START_FLAG} ]; then
rabbitmqctl node_health_check
RESULT=\$?
if [ \$RESULT -ne 0 ]; then
rabbitmqctl status
exit $?
fi
rm -f \${START_FLAG}
exit \${RESULT}
fi
rabbitmq-api-check \$1 \$2
EOF
chmod a+x /opt/bitnami/rabbitmq/sbin/rabbitmq-health-check
{{- if and .Values.persistence.enabled .Values.forceBoot.enabled }}
if [ -d "{{ .Values.persistence.path }}/mnesia/${RABBITMQ_NODENAME}" ]; then rabbitmqctl force_boot; fi
{{- end }}
@@ -138,7 +156,7 @@ spec:
command:
- sh
- -c
- rabbitmq-api-check "http://{{ .Values.rabbitmq.username }}:$RABBITMQ_PASSWORD@127.0.0.1:{{ .Values.service.managerPort }}/api/healthchecks/node" '{"status":"ok"}'
- rabbitmq-api-check "http://{{ .Values.rabbitmq.username }}:$RABBITMQ_PASSWORD@127.0.0.1:{{ .Values.service.managerPort }}/api/healthchecks/node" '{"status":"ok"}'
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
@@ -151,7 +169,7 @@ spec:
command:
- sh
- -c
- rabbitmq-api-check "http://{{ .Values.rabbitmq.username }}:$RABBITMQ_PASSWORD@127.0.0.1:{{ .Values.service.managerPort }}/api/healthchecks/node" '{"status":"ok"}'
- rabbitmq-health-check "http://{{ .Values.rabbitmq.username }}:$RABBITMQ_PASSWORD@127.0.0.1:{{ .Values.service.managerPort }}/api/healthchecks/node" '{"status":"ok"}'
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}