tripleo-upgrade/templates/check_service_haproxy.sh.j2

27 lines
1.3 KiB
Django/Jinja

source {{ undercloud_rc }}
OC_USER="{{ (overcloud_ssh_user) | ternary(overcloud_ssh_user, 'heat-admin') }}"
NODE_IP=$(openstack server show {{ node_name | splitext | first }} -f json | jq -r .addresses | grep -oP '[0-9.]+')
## in case of external loadbalancer haproxy resource is not running on controller nodes
EXT_LB=$(ssh -q -o StrictHostKeyChecking=no $OC_USER@$NODE_IP 'sudo hiera -c /etc/puppet/hiera.yaml enable_load_balancer')
if [[ $EXT_LB != 'false' ]]; then
## wait for haproxy resource to come back up
timeout_seconds={{ node_reboot_timeout }}
elapsed_seconds=0
while true; do
echo "Waiting for haproxy pcs resource to start"
HAPROXY_RES=$(ssh -q -o StrictHostKeyChecking=no $OC_USER@$NODE_IP 'sudo pcs status --full' | grep haproxy-bundle | grep -i started | wc -l)
if [[ $HAPROXY_RES = 1 ]] || [[ $HAPROXY_RES > 2 ]]; then
echo "${HAPROXY_RES} instances of haproxy-bundle are started"
break
fi
sleep 3
(( elapsed_seconds += 3 ))
if [ $elapsed_seconds -ge $timeout_seconds ]; then
echo "FAILURE: Haproxy pcs resource didn't get started after reboot"
ssh -q -o StrictHostKeyChecking=no $OC_USER@$NODE_IP 'sudo pcs status --full' | grep 'haproxy-bundle'
exit 1
fi
done
fi