Merge "Add Management net to ips-from-pool-all example"
[apex-tripleo-heat-templates.git] / extraconfig / tasks / major_upgrade_controller_pacemaker_1.sh
1 #!/bin/bash
2
3 set -eu
4
5 cluster_sync_timeout=1800
6
7 if pcs status 2>&1 | grep -E '(cluster is not currently running)|(OFFLINE:)'; then
8     echo_error "ERROR: upgrade cannot start with some cluster nodes being offline"
9     exit 1
10 fi
11
12
13 # We want to disable fencing during the cluster --stop as it might fence
14 # nodes where a service fails to stop, which could be fatal during an upgrade
15 # procedure. So we remember the stonith state. If it was enabled we reenable it
16 # at the end of this script
17 STONITH_STATE=$(pcs property show stonith-enabled | grep "stonith-enabled" | awk '{ print $2 }')
18 pcs property set stonith-enabled=false
19
20 if [ "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]; then
21     pcs resource disable httpd
22     check_resource httpd stopped 1800
23     pcs resource disable openstack-core
24     check_resource openstack-core stopped 1800
25     pcs resource disable redis
26     check_resource redis stopped 600
27     pcs resource disable mongod
28     check_resource mongod stopped 600
29     pcs resource disable rabbitmq
30     check_resource rabbitmq stopped 600
31     pcs resource disable memcached
32     check_resource memcached stopped 600
33     pcs resource disable galera
34     check_resource galera stopped 600
35     # Disable all VIPs before stopping the cluster, so that pcs doesn't use one as a source address:
36     #   https://bugzilla.redhat.com/show_bug.cgi?id=1330688
37     for vip in $(pcs resource show | grep ocf::heartbeat:IPaddr2 | grep Started | awk '{ print $1 }'); do
38       pcs resource disable $vip
39       check_resource $vip stopped 60
40     done
41     pcs cluster stop --all
42 fi
43
44 # Swift isn't controled by pacemaker
45 systemctl_swift stop
46
47 tstart=$(date +%s)
48 while systemctl is-active pacemaker; do
49     sleep 5
50     tnow=$(date +%s)
51     if (( tnow-tstart > cluster_sync_timeout )) ; then
52         echo_error "ERROR: cluster shutdown timed out"
53         exit 1
54     fi
55 done
56
57 yum -y install python-zaqarclient  # needed for os-collect-config
58 yum -y -q update
59
60
61 # Let's reset the stonith back to true if it was true, before starting the cluster
62 if [ $STONITH_STATE == "true" ]; then
63     pcs -f /var/lib/pacemaker/cib/cib.xml property set stonith-enabled=true
64 fi
65
66 # Pin messages sent to compute nodes to kilo, these will be upgraded later
67 crudini  --set /etc/nova/nova.conf upgrade_levels compute "$upgrade_level_nova_compute"
68 # https://bugzilla.redhat.com/show_bug.cgi?id=1284047
69 # Change-Id: Ib3f6c12ff5471e1f017f28b16b1e6496a4a4b435
70 crudini  --set /etc/ceilometer/ceilometer.conf DEFAULT rpc_backend rabbit
71 # https://bugzilla.redhat.com/show_bug.cgi?id=1284058
72 # Ifd1861e3df46fad0e44ff9b5cbd58711bbc87c97 Swift Ceilometer middleware no longer exists
73 crudini --set /etc/swift/proxy-server.conf pipeline:main pipeline "catch_errors healthcheck cache ratelimit tempurl formpost authtoken keystone staticweb proxy-logging proxy-server"