Skip to content

Commit 1a1a385

Browse files
committed
Refactor RabbitMQ migration playbook into script
1 parent ad8aa2a commit 1a1a385

File tree

2 files changed

+56
-114
lines changed

2 files changed

+56
-114
lines changed

etc/kayobe/ansible/migrate-rabbitmq-queues.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

tools/rabbitmq-quorum-migration.sh

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

0 commit comments

Comments
 (0)