Skip to content

Commit cc8ebe9

Browse files
committed
wip
1 parent ad8aa2a commit cc8ebe9

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# Migrate RabbitMQ queues from HA to Quorum
3+
# This is primarily used in CI workflows
4+
5+
- name: Migrate RabbitMQ queues
6+
hosts: controllers
7+
gather_facts: no
8+
vars:
9+
- rabbitmq_container_name: "rabbitmq"
10+
- services_to_restart: "barbican,blazar,cinder,cloudkitty,designate,heat,ironic,keystone,magnum,manila,neutron,nova,octavia"
11+
tasks:
12+
- name: Inspect RabbitMQ queues
13+
shell:
14+
cmd: "docker exec {{ rabbitmq_container_name }} rabbitmqctl list_queues type"
15+
run_once: true
16+
delegate_to: localhost
17+
register: queues
18+
become: true
19+
20+
- name: Assert that queues have been migrated
21+
assert:
22+
that: "{{ 'quorum' in queues.stdout }}"
23+
fail_msg: Queue migration has failed. Run the migration manually.
24+
run_once: true
25+
delegate_to: localhost

etc/kayobe/ansible/migrate-rabbitmq-queues.yml renamed to etc/kayobe/ansible/rabbitmq-migration-prechecks.yml

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -66,49 +66,3 @@
6666
command: "docker exec {{ rabbitmq_container_name }} /bin/bash -c 'rabbitmqctl wait /var/lib/rabbitmq/mnesia/rabbitmq.pid --timeout 60'"
6767
when: inspection.stdout == 'false'
6868
become: true
69-
70-
- name: Generate new configuration and stop services
71-
shell:
72-
cmd: >
73-
kayobe overcloud service configuration generate --node-config-dir /etc/kolla --kolla-skip-tags rabbitmq-ha-precheck &&
74-
kayobe kolla ansible run "stop --yes-i-really-really-mean-it" -kt {{ services_to_restart }} &&
75-
kayobe kolla ansible run rabbitmq-reset-state
76-
executable: /bin/bash
77-
run_once: true
78-
delegate_to: localhost
79-
tags: rabbit-queue-migration
80-
81-
- name: Ensure that no queues exist
82-
shell:
83-
cmd: >
84-
docker exec rabbitmq rabbitmqctl list_queues name --silent &&
85-
docker exec rabbitmq rabbitmqctl list_exchanges name --silent
86-
| grep -v '^$'
87-
| (! grep -v 'amq.')
88-
executable: /bin/bash
89-
become: true
90-
register: queues
91-
92-
- name: Redeploy services with quorum queues
93-
shell:
94-
cmd: >
95-
kayobe kolla ansible run deploy -kt {{ services_to_restart }}
96-
executable: /bin/bash
97-
run_once: true
98-
delegate_to: localhost
99-
tags: rabbit-queue-migration
100-
101-
- name: Inspect RabbitMQ queues
102-
shell:
103-
cmd: "docker exec {{ rabbitmq_container_name }} rabbitmqctl list_queues type"
104-
run_once: true
105-
delegate_to: localhost
106-
register: queues
107-
become: true
108-
109-
- name: Assert that queues have been migrated
110-
assert:
111-
that: "{{ 'quorum' in queues.stdout }}"
112-
fail_msg: Queue migration has failed. Run the migration manually.
113-
run_once: true
114-
delegate_to: localhost

tools/rabbitmq-quorum-migration.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#! /usr/bin/bash
2+
3+
RABBITMQ_SERVICES_TO_RESTART=barbican,blazar,cinder,cloudkitty,designate,heat,ironic,keystone,magnum,manila,neutron,nova,octavia
4+
RABBITMQ_CONTAINER_NAME=rabbitmq
5+
6+
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
7+
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
8+
echo "Ensure your environment is set up to run kayobe commands"
9+
exit 2
10+
fi
11+
12+
if [[ ! "$1" = "--skip-checks" ]]; then
13+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/rabbitmq-migration-prechecks.yml -e services_to_restart=$RABBITMQ_SERVICES_TO_RESTART -e rabbitmq_container_name=$RABBITMQ_CONTAINER_NAME
14+
fi
15+
16+
kayobe overcloud service configuration generate --node-config-dir /etc/kolla --kolla-skip-tags rabbitmq-ha-precheck &&
17+
kayobe kolla ansible run "stop --yes-i-really-really-mean-it" -kt $RABBITMQ_SERVICES_TO_RESTART &&
18+
kayobe kolla ansible run rabbitmq-reset-state
19+
if [[ ! "$1" = "--skip-checks" ]]; then
20+
kayobe overcloud host command run -l controllers -b --command "(docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues name --silent && docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_exchanges name --silent) | grep -v '^$' | (! grep -v 'amq.')"
21+
fi
22+
kayobe kolla ansible run deploy -kt {{ services_to_restart }}
23+
24+
if [[ ! "$1" = "--skip-checks" ]]; then
25+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/rabbitmq-migration-postchecks.yml -e services_to_restart=$RABBITMQ_SERVICES_TO_RESTART -e rabbitmq_container_name=$RABBITMQ_CONTAINER_NAME
26+
fi
27+
28+

0 commit comments

Comments
 (0)