Skip to content

Commit 6281412

Browse files
authored
Merge pull request #1224 from stackhpc/rabbit-upgrade
Add RabbitMQ Quorum queue migration playbook
2 parents dcea903 + 9cfefa6 commit 6281412

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

etc/kayobe/environments/ci-aio/kolla/globals.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ opensearch_heap_size: 200m
1414

1515
# Increase Grafana timeout
1616
grafana_start_first_node_retries: 20
17+
18+
# Ensure Rabbit is deployed with HA rather than quorum queues (to test migrations)
19+
om_enable_rabbitmq_high_availability: true
20+
om_enable_rabbitmq_quorum_queues: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Added a script to automate RabbitMQ quorum queue migrations.

tools/rabbitmq-quorum-migration.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
# Fail if clocks are not 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+
# Fail if HA is set or quorum 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+
35+
if [[ ! "$1" = "--skip-checks" ]]; then
36+
# Fail if any queues still exist
37+
sleep 20
38+
if kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues name --silent | grep -v '^$'"; then
39+
echo "Failed check: RabbitMQ has not stopped properly, queues still exist"
40+
exit 1
41+
fi
42+
# Fail if any exchanges still exist (excluding those starting with 'amq.')
43+
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
44+
echo "Failed check: RabbitMQ has not stopped properly, exchanges still exist"
45+
exit 1
46+
fi
47+
fi
48+
49+
# Redeploy with quorum queues enabled
50+
kayobe kolla ansible run deploy-containers -kt $RABBITMQ_SERVICES_TO_RESTART
51+
52+
if [[ ! "$1" = "--skip-checks" ]]; then
53+
sleep 20
54+
# Assert that at least one quorum queue exists on each controller
55+
if kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues type | grep quorum"; then
56+
echo "Queues migrated successfully"
57+
else
58+
echo "Failed post-check: A controller does not have any quorum queues"
59+
fi
60+
fi

0 commit comments

Comments
 (0)