-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrabbitmq-quorum-migration.sh
executable file
·63 lines (55 loc) · 3.06 KB
/
rabbitmq-quorum-migration.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/bash
set -ex
RABBITMQ_CRITICAL_SERVICES_TO_RESTART=keystone,neutron
RABBITMQ_SERVICES_TO_RESTART=barbican,blazar,cinder,cloudkitty,designate,heat,ironic,magnum,manila,nova,octavia
RABBITMQ_CONTAINER_NAME=rabbitmq
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
echo "Ensure your environment is set up to run kayobe commands"
exit 2
fi
if [[ ! "$1" = "--skip-checks" ]]; then
# Fail if clocks are not synced
if ! ( kayobe overcloud host command run -l controllers -b --command "timedatectl status | grep 'synchronized: yes'" ); then
echo "Failed precheck: Time not synced on controllers"
echo "Use 'timedatectl status' to check sync state"
echo "Either wait for sync or use 'chronyc makestep'"
exit 1
fi
kayobe overcloud service configuration generate --node-config-dir /tmp/rabbit-migration --kolla-tags none
# Fail if HA is set or quorum is not
if ! ( grep 'om_enable_rabbitmq_quorum_queues: true' $KOLLA_CONFIG_PATH/globals.yml || grep 'om_enable_rabbitmq_high_availability: true' $KOLLA_CONFIG_PATH/globals.yml ); then
echo "Failed precheck: om_enable_rabbitmq_quorum_queues must be enabled, om_enable_rabbitmq_high_availability must be disabled"
exit 1
fi
fi
# Generate new config, stop services using rabbit, and reset rabbit state
kayobe overcloud service configuration generate --node-config-dir /etc/kolla --kolla-skip-tags rabbitmq-ha-precheck
kayobe kolla ansible run "stop --yes-i-really-really-mean-it" -kt $RABBITMQ_SERVICES_TO_RESTART
kayobe kolla ansible run "stop --yes-i-really-really-mean-it" -kt $RABBITMQ_CRITICAL_SERVICES_TO_RESTART
kayobe kolla ansible run rabbitmq-reset-state
if [[ ! "$1" = "--skip-checks" ]]; then
# Fail if any queues still exist
sleep 20
if ( kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues name --silent | grep -v '^$'" ); then
echo "Failed check: RabbitMQ has not stopped properly, queues still exist"
exit 1
fi
# Fail if any exchanges still exist (excluding those starting with 'amq.')
if ( kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_exchanges name --silent | grep -v '^$' | grep -v '^amq.'" ); then
echo "Failed check: RabbitMQ has not stopped properly, exchanges still exist"
exit 1
fi
fi
# Redeploy with quorum queues enabled
kayobe kolla ansible run deploy-containers -kt $RABBITMQ_CRITICAL_SERVICES_TO_RESTART
kayobe kolla ansible run deploy-containers -kt $RABBITMQ_SERVICES_TO_RESTART
if [[ ! "$1" = "--skip-checks" ]]; then
sleep 20
# Assert that at least one quorum queue exists on each controller
if ( kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues type | grep quorum" ); then
echo "Queues migrated successfully"
else
echo "Failed post-check: A controller does not have any quorum queues"
fi
fi