Skip to content

Commit be31d10

Browse files
committed
Add RabbitMQ Quorum queue migration playbook
1 parent e647aa1 commit be31d10

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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: localhost
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: Checking timedatectl status
13+
command: timedatectl status
14+
register: timedatectl_status
15+
changed_when: false
16+
17+
- name: Generate kolla configuration
18+
shell:
19+
cmd: >
20+
kayobe overcloud service configuration generate --node-config-dir /tmp/rabbit-migration --kolla-tags none
21+
executable: /bin/bash
22+
run_once: true
23+
delegate_to: localhost
24+
changed_when: false
25+
26+
- name: Fail if HA is set or Quorum is unset
27+
shell:
28+
cmd: >
29+
grep 'om_enable_rabbitmq_quorum_queues: true' $KOLLA_CONFIG_PATH/globals.yml &&
30+
! grep 'om_enable_rabbitmq_high_availability: true' $KOLLA_CONFIG_PATH/globals.yml
31+
executable: /bin/bash
32+
run_once: true
33+
delegate_to: localhost
34+
changed_when: false
35+
36+
- name: Fail if the clock is not synchronized
37+
assert:
38+
that:
39+
- "'synchronized: yes' not in timedatectl_status.stdout"
40+
fail_msg: >
41+
timedatectl sees the system clock as unsynchronized.
42+
You may need to force synchronisation using `chronyc makestep`.
43+
Otherwise, please wait for synchronization.
44+
45+
- name: Inspect the {{ rabbitmq_container_name }} container
46+
shell:
47+
cmd: "docker container inspect --format '{{ '{{' }} .State.Running {{ '}}' }}' {{ rabbitmq_container_name }}"
48+
register: inspection
49+
become: true
50+
51+
- name: Ensure the {{ rabbitmq_container_name }} container is running
52+
command: "systemctl start kolla-{{ rabbitmq_container_name }}-container.service"
53+
when: inspection.stdout == 'false'
54+
become: true
55+
56+
- name: Wait for the {{ rabbitmq_container_name }} container to reach state 'Running'
57+
shell:
58+
cmd: "docker container inspect --format '{{ '{{' }} .State.Running {{ '}}' }}' {{ rabbitmq_container_name }}"
59+
register: result
60+
until: result.stdout == 'true'
61+
retries: 10
62+
delay: 6
63+
become: true
64+
65+
- name: Wait for the rabbitmq node to automatically start on container start
66+
command: "docker exec {{ rabbitmq_container_name }} /bin/bash -c 'rabbitmqctl wait /var/lib/rabbitmq/mnesia/rabbitmq.pid --timeout 60'"
67+
when: inspection.stdout == 'false'
68+
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
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 new playbook to automate RabbitMQ Quorum queue migrations.

0 commit comments

Comments
 (0)