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
22 if [ "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]; then
26 # After migrating the cluster to HA-NG the services not under pacemaker's control
27 # are still up and running. We need to stop them explicitely otherwise during the yum
28 # upgrade the rpm %post sections will try to do a systemctl try-restart <service>, which
29 # is going to take a long time because rabbit is down. By having the service stopped
30 # systemctl try-restart is a noop
32 for $service in $(services_to_migrate); do
33 manage_systemd_service stop "${service%%-clone}"
34 check_resource_systemd "${service%%-clone}" stopped 600
37 # In case the mysql package is updated, the database on disk must be
38 # upgraded as well. This typically needs to happen during major
39 # version upgrades (e.g. 5.5 -> 5.6, 5.5 -> 10.1...)
41 # Because in-place upgrades are not supported across 2+ major versions
42 # (e.g. 5.5 -> 10.1), we rely on logical upgrades via dump/restore cycle
43 # https://bugzilla.redhat.com/show_bug.cgi?id=1341968
45 # The default is to determine automatically if upgrade is needed based
46 # on mysql package versionning, but this can be overriden manually
47 # to support specific upgrade scenario
49 if [ "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]; then
50 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
51 mysqldump $backup_flags > "$MYSQL_BACKUP_DIR/openstack_database.sql"
52 cp -rdp /etc/my.cnf* "$MYSQL_BACKUP_DIR"
55 pcs resource disable redis
56 check_resource redis stopped 600
57 pcs resource disable rabbitmq
58 check_resource rabbitmq stopped 600
59 pcs resource disable galera
60 check_resource galera stopped 600
61 # Disable all VIPs before stopping the cluster, so that pcs doesn't use one as a source address:
62 # https://bugzilla.redhat.com/show_bug.cgi?id=1330688
63 for vip in $(pcs resource show | grep ocf::heartbeat:IPaddr2 | grep Started | awk '{ print $1 }'); do
64 pcs resource disable $vip
65 check_resource $vip stopped 60
67 pcs cluster stop --all
71 # Swift isn't controled by pacemaker
75 while systemctl is-active pacemaker; do
78 if (( tnow-tstart > cluster_sync_timeout )) ; then
79 echo_error "ERROR: cluster shutdown timed out"
84 # The reason we do an sql dump *and* we move the old dir out of
85 # the way is because it gives us an extra level of safety in case
86 # something goes wrong during the upgrade. Once the restore is
87 # successful we go ahead and remove it. If the directory exists
88 # we bail out as it means the upgrade process had issues in the last
90 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
91 if [ -d $MYSQL_TEMP_UPGRADE_BACKUP_DIR ]; then
92 echo_error "ERROR: mysql backup dir already exist"
95 mv /var/lib/mysql $MYSQL_TEMP_UPGRADE_BACKUP_DIR
98 yum -y install python-zaqarclient # needed for os-collect-config
101 # We need to ensure at least those two configuration settings, otherwise
102 # mariadb 10.1+ won't activate galera replication.
103 # wsrep_cluster_address must only be set though, its value does not
104 # matter because it's overriden by the galera resource agent.
105 cat >> /etc/my.cnf.d/galera.cnf <<EOF
108 wsrep_cluster_address = gcomm://localhost
111 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
112 # Scripts run via heat have no HOME variable set and this confuses
116 mkdir /var/lib/mysql || /bin/true
117 chown mysql:mysql /var/lib/mysql
118 chmod 0755 /var/lib/mysql
119 restorecon -R /var/lib/mysql/
120 mysql_install_db --datadir=/var/lib/mysql --user=mysql
121 chown -R mysql:mysql /var/lib/mysql/
123 if [ "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]; then
124 mysqld_safe --wsrep-new-cluster &
125 # We have a populated /root/.my.cnf with root/password here so
126 # we need to temporarily rename it because the newly created
127 # db is empty and no root password is set
128 mv /root/.my.cnf /root/.my.cnf.temporary
129 timeout 60 sh -c 'while ! mysql -e "" &> /dev/null; do sleep 1; done'
130 mysql -u root < "$MYSQL_BACKUP_DIR/openstack_database.sql"
131 mv /root/.my.cnf.temporary /root/.my.cnf
132 mysqladmin -u root shutdown
133 # The import was successful so we may remove the folder
134 rm -r "$MYSQL_BACKUP_DIR"
138 # If we reached here without error we can safely blow away the origin
139 # mysql dir from every controller
141 # TODO: What if the upgrade fails on the bootstrap node, but not on
142 # this controller. Data may be lost.
143 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
144 rm -r $MYSQL_TEMP_UPGRADE_BACKUP_DIR
147 # Let's reset the stonith back to true if it was true, before starting the cluster
148 if [ $STONITH_STATE == "true" ]; then
149 pcs -f /var/lib/pacemaker/cib/cib.xml property set stonith-enabled=true
152 # Pin messages sent to compute nodes to kilo, these will be upgraded later
153 crudini --set /etc/nova/nova.conf upgrade_levels compute "$upgrade_level_nova_compute"
155 crudini --set /etc/sahara/sahara.conf DEFAULT plugins ambari,cdh,mapr,vanilla,spark,storm