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)
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 }')
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
60 function add_missing_openstack_core_constraints {
61 # The CIBs are saved under /root as they might contain sensitive data
62 CIB="/root/migration.cib"
63 CIB_BACKUP="/root/backup.cib"
66 rm -f "$CIB" "$CIB_BACKUP" || /bin/true
67 pcs cluster cib "$CIB"
68 cp "$CIB" "$CIB_BACKUP"
70 if ! pcs -f "$CIB" constraint --full | grep 'start openstack-sahara-api-clone then start openstack-sahara-engine-clone'; then
71 pcs -f "$CIB" constraint order start openstack-sahara-api-clone then start openstack-sahara-engine-clone
75 if ! pcs -f "$CIB" constraint --full | grep 'start openstack-core-clone then start openstack-ceilometer-notification-clone'; then
76 pcs -f "$CIB" constraint order start openstack-core-clone then start openstack-ceilometer-notification-clone
80 if ! pcs -f "$CIB" constraint --full | grep 'start openstack-aodh-evaluator-clone then start openstack-aodh-listener-clone'; then
81 pcs -f "$CIB" constraint order start openstack-aodh-evaluator-clone then start openstack-aodh-listener-clone
85 if pcs -f "$CIB" constraint --full | grep 'start openstack-core-clone then start openstack-heat-api-clone'; then
86 CID=$(pcs -f "$CIB" constraint --full | grep 'start openstack-core-clone then start openstack-heat-api-clone' | sed -e 's/.*id\://g' -e 's/)//g')
87 pcs -f "$CIB" constraint remove $CID
91 if [ "$CIB_PUSH_NEEDED" = 'y' ]; then
92 pcs cluster cib-push "$CIB"
96 function remove_ceilometer_alarm {
97 if pcs status | grep openstack-ceilometer-alarm; then
98 # Disable pacemaker resources for ceilometer-alarms
99 pcs resource disable openstack-ceilometer-alarm-evaluator
100 check_resource openstack-ceilometer-alarm-evaluator stopped 600
101 pcs resource delete openstack-ceilometer-alarm-evaluator
102 pcs resource disable openstack-ceilometer-alarm-notifier
103 check_resource openstack-ceilometer-alarm-notifier stopped 600
104 pcs resource delete openstack-ceilometer-alarm-notifier
107 pcs constraint remove ceilometer-delay-then-ceilometer-alarm-evaluator-constraint
108 pcs constraint remove ceilometer-alarm-evaluator-with-ceilometer-delay-colocation
109 pcs constraint remove ceilometer-alarm-evaluator-then-ceilometer-alarm-notifier-constraint
110 pcs constraint remove ceilometer-alarm-notifier-with-ceilometer-alarm-evaluator-colocation
111 pcs constraint remove ceilometer-alarm-notifier-then-ceilometer-notification-constraint
112 pcs constraint remove ceilometer-notification-with-ceilometer-alarm-notifier-colocation
116 # uninstall openstack-ceilometer-alarm package
117 yum -y remove openstack-ceilometer-alarm