Rework gnocchi-upgrade to run in a separate upgrade step
[apex-tripleo-heat-templates.git] / extraconfig / tasks / major_upgrade_controller_pacemaker_2.sh
1 #!/bin/bash
2
3 set -eu
4
5 cluster_form_timeout=600
6 cluster_settle_timeout=1800
7 galera_sync_timeout=600
8
9 if [[ -n $(is_bootstrap_node) ]]; then
10     pcs cluster start --all
11
12     tstart=$(date +%s)
13     while pcs status 2>&1 | grep -E '(cluster is not currently running)|(OFFLINE:)'; do
14         sleep 5
15         tnow=$(date +%s)
16         if (( tnow-tstart > cluster_form_timeout )) ; then
17             echo_error "ERROR: timed out forming the cluster"
18             exit 1
19         fi
20     done
21
22     if ! timeout -k 10 $cluster_settle_timeout crm_resource --wait; then
23         echo_error "ERROR: timed out waiting for cluster to finish transition"
24         exit 1
25     fi
26
27     for vip in $(pcs resource show | grep ocf::heartbeat:IPaddr2 | grep Stopped | awk '{ print $1 }'); do
28       pcs resource enable $vip
29       check_resource_pacemaker $vip started 60
30     done
31 fi
32
33 start_or_enable_service galera
34 check_resource galera started 600
35 start_or_enable_service redis
36 check_resource redis started 600
37 # We need mongod which is now a systemd service up and running before calling
38 # ceilometer-dbsync. There is still a race here: mongod might not be up on all nodes
39 # so ceilometer-dbsync will fail a couple of times before that. As it retries indefinitely
40 # we should be good.
41 # Due to LP Bug https://bugs.launchpad.net/tripleo/+bug/1627254 am using systemctl directly atm
42 systemctl start mongod
43 check_resource mongod started 600
44
45 if [[ -n $(is_bootstrap_node) ]]; then
46     tstart=$(date +%s)
47     while ! clustercheck; do
48         sleep 5
49         tnow=$(date +%s)
50         if (( tnow-tstart > galera_sync_timeout )) ; then
51             echo_error "ERROR galera sync timed out"
52             exit 1
53         fi
54     done
55
56     # Run all the db syncs
57     # TODO: check if this can be triggered in puppet and removed from here
58     ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf
59     cinder-manage db sync
60     glance-manage --config-file=/etc/glance/glance-registry.conf db_sync
61     heat-manage --config-file /etc/heat/heat.conf db_sync
62     keystone-manage db_sync
63     neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head
64     nova-manage db sync
65     nova-manage api_db sync
66     nova-manage db online_data_migrations
67     sahara-db-manage --config-file /etc/sahara/sahara.conf upgrade head
68 fi