healthchecks: implement service-specific checks

This introduces health checks for a number of OpenStack services.

Change-Id: I9882d5047c960499dae279eda5d9cbacc01ac5d3
Implements: blueprint container-healthchecks
This commit is contained in:
Lars Kellogg-Stedman 2017-07-12 16:16:46 -04:00 committed by Martin Mágr
parent 12538270b7
commit 23468032b3
8 changed files with 75 additions and 3 deletions

19
healthcheck/README.md Normal file
View File

@ -0,0 +1,19 @@
# Health check commands
The scripts in this directory are meant to implement the
[container-healthcheck][] blueprint. They are written to be compatible
with the Docker [HEALTHCHECK][] api.
[container-healthcheck]: https://blueprints.launchpad.net/tripleo/+spec/container-healthchecks
[healthcheck]: https://docs.docker.com/engine/reference/builder/#healthcheck
The scripts expect to source
`/usr/share/tripleo-common/healthcheck/common.sh`. If you
want to run scripts without installing to that file, you can set the
`HEALTHCHECKS_DIR` environment variable, e.g:
$ export HEALTHCHECKS_DIR=$PWD
$ ./heat-api
{"versions": [{"status": "CURRENT", "id": "v1.0", "links": [{"href": "http://192.168.24.1:8004/v1/", "rel": "self"}]}]}
300 192.168.24.1:8004 0.002 seconds

15
healthcheck/common.sh Normal file
View File

@ -0,0 +1,15 @@
: ${HEALTHCHECK_CURL_MAX_TIME:=10}
: ${HEALTHCHECK_CURL_USER_AGENT:=curl-healthcheck}
: ${HEALTHCHECK_CURL_WRITE_OUT:='\n%{http_code} %{remote_ip}:%{remote_port} %{time_total} seconds\n'}
healthcheck_curl () {
curl -q --fail \
--max-time "${HEALTHCHECK_CURL_MAX_TIME}" \
--user-agent "${HEALTHCHECK_CURL_USER_AGENT}" \
--write-out "${HEALTHCHECK_CURL_WRITE_OUT}" \
"$@" || return 1
}
get_config_val () {
crudini --get "$1" "$2" "$3" 2> /dev/null || echo "$4"
}

8
healthcheck/glance-api Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
. ${HEALTHCHECK_SCRIPTS:-/usr/share/tripleo-common/healthcheck}/common.sh
bind_host=$(get_config_val /etc/glance/glance-api.conf DEFAULT bind_host 127.0.0.1)
bind_port=$(get_config_val /etc/glance/glance-api.conf DEFAULT bind_port 9292)
healthcheck_curl http://${bind_host}:${bind_port}/

View File

@ -1,5 +1,7 @@
#!/bin/sh
bind_host=$(crudini --get /etc/heat/heat.conf heat_api bind_host 2> /dev/null || echo 127.0.0.1)
bind_port=$(crudini --get /etc/heat/heat.conf heat_api bind_port 2> /dev/null || echo 8004)
curl --fail http://${bind_host}:${bind_port}/ || exit 1
. ${HEALTHCHECK_SCRIPTS:-/usr/share/tripleo-common/healthcheck}/common.sh
bind_host=$(get_config_val /etc/heat/heat.conf heat_api bind_host 127.0.0.1)
bind_port=$(get_config_val /etc/heat/heat.conf heat_api bind_port 8004)
healthcheck_curl http://${bind_host}:${bind_port}/

7
healthcheck/heat-api-cfn Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
. ${HEALTHCHECK_SCRIPTS:-/usr/share/tripleo-common/healthcheck}/common.sh
bind_host=$(get_config_val /etc/heat/heat.conf heat_api_cfn bind_host 127.0.0.1)
bind_port=$(get_config_val /etc/heat/heat.conf heat_api_cfn bind_port 8000)
healthcheck_curl http://${bind_host}:${bind_port}/

7
healthcheck/keystone-admin Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
. ${HEALTHCHECK_SCRIPTS:-/usr/share/tripleo-common/healthcheck}/common.sh
bind_host=$(get_config_val /etc/keystone/keystone.conf DEFAULT admin_bind_host 127.0.0.1)
bind_port=$(get_config_val /etc/keystone/keystone.conf DEFAULT admin_port 5000)
healthcheck_curl http://${bind_host}:${bind_port}/

7
healthcheck/keystone-public Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
. ${HEALTHCHECK_SCRIPTS:-/usr/share/tripleo-common/healthcheck}/common.sh
bind_host=$(get_config_val /etc/keystone/keystone.conf DEFAULT public_bind_host 127.0.0.1)
bind_port=$(get_config_val /etc/keystone/keystone.conf DEFAULT public_port 5000)
healthcheck_curl http://${bind_host}:${bind_port}/

7
healthcheck/nova-api Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
. ${HEALTHCHECK_SCRIPTS:-/usr/share/tripleo-common/healthcheck}/common.sh
bind_host=$(get_config_val /etc/nova/nova.conf DEFAULT osapi_compute_listen 127.0.0.1)
bind_port=$(get_config_val /etc/nova/nova.conf DEFAULT osapi_compute_listen_port 8774)
healthcheck_curl http://${bind_host}:${bind_port}/