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"
15 if pcs status 2>&1 | grep -E 'Offline'; then
16 echo_error "ERROR: upgrade cannot start with some pcsd daemon offline"
23 # Shall we upgrade mysql data directory during the stack upgrade?
24 if [ "$mariadb_do_major_upgrade" = "auto" ]; then
25 ret=$(is_mysql_upgrade_needed)
26 if [ $ret = "1" ]; then
31 echo "mysql upgrade required: $DO_MYSQL_UPGRADE"
32 elif [ "$mariadb_do_major_upgrade" = "no" ]; then
39 check_disk_for_mysql_dump()
41 # Where to backup current database if mysql need to be upgraded
42 MYSQL_BACKUP_DIR=/var/tmp/mysql_upgrade_osp
43 MYSQL_TEMP_UPGRADE_BACKUP_DIR=/var/lib/mysql-temp-upgrade-backup
44 # Spare disk ratio for extra safety
45 MYSQL_BACKUP_SIZE_RATIO=1.2
49 if [ "$(hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid)" = "$(facter hostname)" ]; then
50 if [ $DO_MYSQL_UPGRADE -eq 1 ]; then
52 if [ -d "$MYSQL_BACKUP_DIR" ]; then
53 echo_error "Error: $MYSQL_BACKUP_DIR exists already. Likely an upgrade failed previously"
56 mkdir "$MYSQL_BACKUP_DIR"
58 echo_error "Error: could not create temporary backup directory $MYSQL_BACKUP_DIR"
62 # the /root/.my.cnf is needed because we set the mysql root
63 # password from liberty onwards
64 backup_flags="--defaults-extra-file=/root/.my.cnf -u root --flush-privileges --all-databases --single-transaction"
65 # While not ideal, this step allows us to calculate exactly how much space the dump
66 # will need. Our main goal here is avoiding any chance of corruption due to disk space
68 backup_size=$(mysqldump $backup_flags 2>/dev/null | wc -c)
69 database_size=$(du -cb /var/lib/mysql | tail -1 | awk '{ print $1 }')
70 free_space=$(df -B1 --output=avail "$MYSQL_BACKUP_DIR" | tail -1)
72 # we need at least space for a new mysql database + dump of the existing one,
73 # times a small factor for additional safety room
74 # note: bash doesn't do floating point math or floats in if statements,
75 # so use python to apply the ratio and cast it back to integer
76 required_space=$(python -c "from __future__ import print_function; print(\"%d\" % int((($database_size + $backup_size) * $MYSQL_BACKUP_SIZE_RATIO)))")
77 if [ $required_space -ge $free_space ]; then
78 echo_error "Error: not enough free space in $MYSQL_BACKUP_DIR ($required_space bytes required)"
87 # If for some reason rpm-python are missing we want to error out early enough
88 if ! rpm -q rpm-python &> /dev/null; then
89 echo_error "ERROR: upgrade cannot start without rpm-python installed"
96 if pcs status | grep -q Stopped:; then
97 echo_error "ERROR: upgrade cannot start with stopped resources on the cluster. Make sure that all the resources are up and running."
102 check_galera_root_password()
105 if [ ! -e /root/.my.cnf ]; then
106 echo_error "ERROR: upgrade cannot be started, the galera password is missing. The overcloud needs update."