5 cluster_sync_timeout=1800
11 check_galera_root_password
12 check_disk_for_mysql_dump
14 # We want to disable fencing during the cluster --stop as it might fence
15 # nodes where a service fails to stop, which could be fatal during an upgrade
16 # procedure. So we remember the stonith state. If it was enabled we reenable it
17 # at the end of this script
18 STONITH_STATE=$(pcs property show stonith-enabled | grep "stonith-enabled" | awk '{ print $2 }')
19 pcs property set stonith-enabled=false
21 # In case the mysql package is updated, the database on disk must be
22 # upgraded as well. This typically needs to happen during major
23 # version upgrades (e.g. 5.5 -> 5.6, 5.5 -> 10.1...)
25 # Because in-place upgrades are not supported across 2+ major versions
26 # (e.g. 5.5 -> 10.1), we rely on logical upgrades via dump/restore cycle
27 # https://bugzilla.redhat.com/show_bug.cgi?id=1341968
29 # The default is to determine automatically if upgrade is needed based
30 # on mysql package versionning, but this can be overriden manually
31 # to support specific upgrade scenario
33 if [ "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]; then
34 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
35 mysqldump $backup_flags > "$MYSQL_BACKUP_DIR/openstack_database.sql"
36 cp -rdp /etc/my.cnf* "$MYSQL_BACKUP_DIR"
39 pcs resource disable httpd
40 check_resource httpd stopped 1800
41 pcs resource disable openstack-core
42 check_resource openstack-core stopped 1800
43 pcs resource disable redis
44 check_resource redis stopped 600
45 pcs resource disable mongod
46 check_resource mongod stopped 600
47 pcs resource disable rabbitmq
48 check_resource rabbitmq stopped 600
49 pcs resource disable memcached
50 check_resource memcached stopped 600
51 pcs resource disable galera
52 check_resource galera stopped 600
53 # Disable all VIPs before stopping the cluster, so that pcs doesn't use one as a source address:
54 # https://bugzilla.redhat.com/show_bug.cgi?id=1330688
55 for vip in $(pcs resource show | grep ocf::heartbeat:IPaddr2 | grep Started | awk '{ print $1 }'); do
56 pcs resource disable $vip
57 check_resource $vip stopped 60
59 pcs cluster stop --all
62 # Swift isn't controled by pacemaker
66 while systemctl is-active pacemaker; do
69 if (( tnow-tstart > cluster_sync_timeout )) ; then
70 echo_error "ERROR: cluster shutdown timed out"
75 # The reason we do an sql dump *and* we move the old dir out of
76 # the way is because it gives us an extra level of safety in case
77 # something goes wrong during the upgrade. Once the restore is
78 # successful we go ahead and remove it. If the directory exists
79 # we bail out as it means the upgrade process had issues in the last
81 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
82 if [ -d $MYSQL_TEMP_UPGRADE_BACKUP_DIR ]; then
83 echo_error "ERROR: mysql backup dir already exist"
86 mv /var/lib/mysql $MYSQL_TEMP_UPGRADE_BACKUP_DIR
89 yum -y install python-zaqarclient # needed for os-collect-config
92 # We need to ensure at least those two configuration settings, otherwise
93 # mariadb 10.1+ won't activate galera replication.
94 # wsrep_cluster_address must only be set though, its value does not
95 # matter because it's overriden by the galera resource agent.
96 cat >> /etc/my.cnf.d/galera.cnf <<EOF
99 wsrep_cluster_address = gcomm://localhost
102 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
103 # Scripts run via heat have no HOME variable set and this confuses
107 mkdir /var/lib/mysql || /bin/true
108 chown mysql:mysql /var/lib/mysql
109 chmod 0755 /var/lib/mysql
110 restorecon -R /var/lib/mysql/
111 mysql_install_db --datadir=/var/lib/mysql --user=mysql
112 chown -R mysql:mysql /var/lib/mysql/
114 if [ "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]; then
115 mysqld_safe --wsrep-new-cluster &
116 # We have a populated /root/.my.cnf with root/password here so
117 # we need to temporarily rename it because the newly created
118 # db is empty and no root password is set
119 mv /root/.my.cnf /root/.my.cnf.temporary
120 timeout 60 sh -c 'while ! mysql -e "" &> /dev/null; do sleep 1; done'
121 mysql -u root < "$MYSQL_BACKUP_DIR/openstack_database.sql"
122 mv /root/.my.cnf.temporary /root/.my.cnf
123 mysqladmin -u root shutdown
124 # The import was successful so we may remove the folder
125 rm -r "$MYSQL_BACKUP_DIR"
129 # If we reached here without error we can safely blow away the origin
130 # mysql dir from every controller
132 # TODO: What if the upgrade fails on the bootstrap node, but not on
133 # this controller. Data may be lost.
134 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
135 rm -r $MYSQL_TEMP_UPGRADE_BACKUP_DIR
138 # Let's reset the stonith back to true if it was true, before starting the cluster
139 if [ $STONITH_STATE == "true" ]; then
140 pcs -f /var/lib/pacemaker/cib/cib.xml property set stonith-enabled=true
143 # Pin messages sent to compute nodes to kilo, these will be upgraded later
144 crudini --set /etc/nova/nova.conf upgrade_levels compute "$upgrade_level_nova_compute"
145 # https://bugzilla.redhat.com/show_bug.cgi?id=1284047
146 # Change-Id: Ib3f6c12ff5471e1f017f28b16b1e6496a4a4b435
147 crudini --set /etc/ceilometer/ceilometer.conf DEFAULT rpc_backend rabbit
148 # https://bugzilla.redhat.com/show_bug.cgi?id=1284058
149 # Ifd1861e3df46fad0e44ff9b5cbd58711bbc87c97 Swift Ceilometer middleware no longer exists
150 crudini --set /etc/swift/proxy-server.conf pipeline:main pipeline "catch_errors healthcheck cache ratelimit tempurl formpost authtoken keystone staticweb proxy-logging proxy-server"
151 # LP: 1615035, required only for M/N upgrade.
152 crudini --set /etc/nova/nova.conf DEFAULT scheduler_host_manager host_manager