3 # Special pieces of upgrade migration logic go into this
4 # file. E.g. Pacemaker cluster transitions for existing deployments,
5 # matching changes to overcloud_controller_pacemaker.pp (Puppet
6 # handles deployment, this file handles migrations).
8 # This file shouldn't execute any action on its own, all logic should
9 # be wrapped into bash functions. Upgrade scripts will source this
10 # file and call the functions defined in this file where appropriate.
12 # The migration functions should be idempotent. If the migration has
13 # been already applied, it should be possible to call the function
14 # again without damaging the deployment or failing the upgrade.
16 # If the major version of mysql is going to change after the major
17 # upgrade, the database must be upgraded on disk to avoid failures
18 # due to internal incompatibilities between major mysql versions
19 # https://bugs.launchpad.net/tripleo/+bug/1587449
20 # This function detects whether a database upgrade is required
21 # after a mysql package upgrade. It returns 0 when no major upgrade
22 # has to take place, 1 otherwise.
23 function is_mysql_upgrade_needed {
24 # The name of the package which provides mysql might differ
25 # after the upgrade. Consider the generic package name, which
26 # should capture the major version change (e.g. 5.5 -> 10.1)
31 output=$(yum -q check-update $name)
34 if [ $ret -ne 100 ]; then
35 # no updates so we exit
40 local currentepoch=$(rpm -q --qf "%{epoch}" $name)
41 local currentversion=$(rpm -q --qf "%{version}" $name | cut -d. -f-2)
42 local currentrelease=$(rpm -q --qf "%{release}" $name)
43 local newoutput=$(repoquery -a --pkgnarrow=updates --qf "%{epoch} %{version} %{release}\n" $name)
44 local newepoch=$(echo "$newoutput" | awk '{ print $1 }')
45 local newversion=$(echo "$newoutput" | awk '{ print $2 }' | cut -d. -f-2)
46 local newrelease=$(echo "$newoutput" | awk '{ print $3 }')
48 # With this we trigger the dump restore/path if we change either epoch or
49 # version in the package If only the release tag changes we do not do it
50 # FIXME: we could refine this by trying to parse the mariadb version
51 # into X.Y.Z and trigger the update only if X and/or Y change.
52 output=$(python -c "import rpm; rc = rpm.labelCompare((\"$currentepoch\", \"$currentversion\", None), (\"$newepoch\", \"$newversion\", None)); print rc")
53 if [ "$output" != "-1" ]; then