Merge "Use ServerOsCollectConfigData value in output"
[apex-tripleo-heat-templates.git] / extraconfig / tasks / pacemaker_resource_restart.sh
1 #!/bin/bash
2
3 set -eux
4
5 # Run if pacemaker is running, we're the bootstrap node,
6 # and we're updating the deployment (not creating).
7
8 RESTART_FOLDER="/var/lib/tripleo/pacemaker-restarts"
9
10 if [[ -d "$RESTART_FOLDER" && -n $(pcmk_running) && -n $(is_bootstrap_node) ]]; then
11
12     TIMEOUT=600
13     PCS_STATUS_OUTPUT="$(pcs status)"
14     SERVICES_TO_RESTART="$(ls $RESTART_FOLDER)"
15
16     for service in $SERVICES_TO_RESTART; do
17         if ! echo "$PCS_STATUS_OUTPUT" | grep $service; then
18             echo "Service $service not found as a pacemaker resource, cannot restart it."
19             exit 1
20         fi
21     done
22
23     for service in $SERVICES_TO_RESTART; do
24         echo "Restarting $service..."
25         pcs resource restart --wait=$TIMEOUT $service
26         rm -f "$RESTART_FOLDER"/$service
27     done
28
29 fi
30
31 if [ $(systemctl is-active haproxy) = "active" ]; then
32     systemctl reload haproxy
33 fi