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