Adding health check scripts.
This commit is contained in:
parent
ce1e3cf9f8
commit
5d9be8f7a1
|
@ -248,6 +248,16 @@ function ha_relation_changed() {
|
|||
fi
|
||||
}
|
||||
|
||||
function config_changed() {
|
||||
# Save our scriptrc env variables for health checks
|
||||
declare -a env_vars=(
|
||||
'OPENSTACK_PORT_MCASTPORT="$(config-get ha-mcastport)"'
|
||||
'OPENSTACK_SERVICE_API=cinder-api'
|
||||
'OPENSTACK_SERVICE_SCHEDULER=cinder-scheduler'
|
||||
'OPENSTACK_SERVICE_VOLUME=cinder-volume'
|
||||
save_script_rc ${env_vars[@]}
|
||||
}
|
||||
|
||||
arg0=$(basename $0)
|
||||
juju-log "cinder: Attempting to fire hook for: $arg0"
|
||||
case $arg0 in
|
||||
|
@ -269,5 +279,6 @@ case $arg0 in
|
|||
"ha-relation-joined") ha_relation_joined ;;
|
||||
"ha-relation-changed") ha_relation_changed ;;
|
||||
"upgrade-charm") upgrade_charm ;;
|
||||
"config-changed") config_changed ;;
|
||||
*) exit 0
|
||||
esac
|
||||
|
|
|
@ -315,6 +315,43 @@ function get_block_device() {
|
|||
return 0
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Description: Creates an rc file exporting environment variables to a
|
||||
# script_path local to the charm's installed directory.
|
||||
# Any charm scripts run outside the juju hook environment can source this
|
||||
# scriptrc to obtain updated config information necessary to perform health
|
||||
# checks or service changes
|
||||
#
|
||||
# Parameters:
|
||||
# An array of '=' delimited ENV_VAR:value combinations to export.
|
||||
# If optional script_path key is not provided in the array, script_path
|
||||
# defaults to scripts/scriptrc
|
||||
##########################################################################
|
||||
function save_script_rc {
|
||||
if [ ! -n "$JUJU_UNIT_NAME" ]; then
|
||||
echo "Error: Missing JUJU_UNIT_NAME environment variable"
|
||||
exit 1
|
||||
fi
|
||||
# our default unit_path
|
||||
unit_path="/var/lib/juju/units/${JUJU_UNIT_NAME/\//-}/charm/scripts/scriptrc"
|
||||
echo $unit_path
|
||||
tmp_rc="/tmp/${JUJU_UNIT_NAME/\//-}rc"
|
||||
|
||||
echo "#!/bin/bash" > $tmp_rc
|
||||
for env_var in "${@}"
|
||||
do
|
||||
if `echo $env_var | grep -q script_path`; then
|
||||
# well then we need to reset the new unit-local script path
|
||||
unit_path="/var/lib/juju/units/${JUJU_UNIT_NAME/\//-}/charm/${env_var/script_path=/}"
|
||||
else
|
||||
echo "export $env_var" >> $tmp_rc
|
||||
fi
|
||||
done
|
||||
chmod 755 $tmp_rc
|
||||
mv $tmp_rc $unit_path
|
||||
}
|
||||
|
||||
|
||||
HAPROXY_CFG=/etc/haproxy/haproxy.cfg
|
||||
HAPROXY_DEFAULT=/etc/default/haproxy
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
crm node online
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
# Validate that service ports are active
|
||||
HEALTH_DIR=`dirname $0`
|
||||
SCRIPTS_DIR=`dirname $HEALTH_DIR`
|
||||
. $SCRIPTS_DIR/scriptrc
|
||||
set -e
|
||||
|
||||
# Grab any OPENSTACK_PORT* environment variables
|
||||
openstack_ports=`env| awk -F '=' '(/OPENSTACK_PORT/){print $2}'`
|
||||
for port in $openstack_ports
|
||||
do
|
||||
netstat -ln | grep -q $port
|
||||
done
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
# Validate that service is running
|
||||
HEALTH_DIR=`dirname $0`
|
||||
SCRIPTS_DIR=`dirname $HEALTH_DIR`
|
||||
. $SCRIPTS_DIR/scriptrc
|
||||
set -e
|
||||
|
||||
# Grab any OPENSTACK_SERVICE* environment variables
|
||||
openstack_service_names=`env| awk -F '=' '(/OPENSTACK_SERVICE/){print $2}'`
|
||||
for service_name in $openstack_service_names
|
||||
do
|
||||
service $service_name status 2>/dev/null | grep -q running
|
||||
done
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
crm node standby
|
Loading…
Reference in New Issue