aboutsummaryrefslogtreecommitdiffstats
path: root/extraconfig/tasks/pacemaker_resource_restart.sh
blob: 8500bcef5971fc98c7ef989d9ac191d10a664fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

set -eux

# Run if pacemaker is running, we're the bootstrap node,
# and we're updating the deployment (not creating).

RESTART_FOLDER="/var/lib/tripleo/pacemaker-restarts"

if [[ -d "$RESTART_FOLDER" && -n $(pcmk_running) && -n $(is_bootstrap_node) ]]; then

    TIMEOUT=600
    PCS_STATUS_OUTPUT="$(pcs status)"
    SERVICES_TO_RESTART="$(ls $RESTART_FOLDER)"

    for service in $SERVICES_TO_RESTART; do
        if ! echo "$PCS_STATUS_OUTPUT" | grep $service; then
            echo "Service $service not found as a pacemaker resource, cannot restart it."
            exit 1
        fi
    done

    for service in $SERVICES_TO_RESTART; do
        echo "Restarting $service..."
        pcs resource restart --wait=$TIMEOUT $service
        rm -f "$RESTART_FOLDER"/$service
    done

fi

haproxy_status=$(systemctl is-active haproxy)
if [ "$haproxy_status" = "active" ]; then
    systemctl reload haproxy
fi