openstack-helm/rabbitmq/templates/bin/_rabbitmq-readiness.sh.tpl
Seungkyu Ahn d2190de96e Fix rabbitmq readiness script error in k8s v1.7
In Kubernetes version 1.7.x, /proc/1/fd/2 command in rabbitmq readiness
shell script makes an error. Instead of using /proc/1/fd/2, use /dev/null.

Change-Id: Ia4fb7f3130ec1a8fccc125bf11e997b77935e1ba
Closes-bug: 1719763
2017-09-27 11:47:52 +09:00

54 lines
1.4 KiB
Smarty

#!/usr/bin/env bash
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
# This is taken from https://github.com/openstack/fuel-ccp-rabbitmq/blob/master/service/files/rabbitmq-readiness.sh.j2
set -eu
set -o pipefail
exec 1>/dev/null 2>&1
source $(readlink -f $(dirname $0))/rabbitmq-check-helpers.sh
set-log-prefix "readiness:$$"
log-it "Starting readiness probe at $(date +'%Y-%m-%d %H:%M:%S')"
main() {
if [[ "$(marker-state)" == missing ]]; then
log-it "Startup marker missing, probably probe was executed too early"
return 1
fi
if ! is-node-healthy; then
log-it "Node is unhealthy"
return 1
fi
{{ if gt (.Values.pod.replicas.server | int) 1 -}}
if ! is-node-properly-clustered; then
log-it "Node is inconsistent with the rest of the cluster"
return 1
fi
{{- end }}
return 0
}
if main; then
rc=0
else
rc=$?
fi
log-it "Ready to return $rc"
exit $rc