From 4731e7f2b4abbba27bb472e00e28b64315e26cc3 Mon Sep 17 00:00:00 2001 From: Matt Crees Date: Thu, 9 May 2024 17:24:02 +0100 Subject: [PATCH] Add a precheck to catch RMQ SLURP upgrades Given we bump the RabbitMQ version each release, there is a manual upgrade to an intermediary RabbitMQ version needed before a skip-level upgrade can be performed. Change-Id: Id8a5ebe19a50ebdc59d12667889472c803b8d7c8 --- ansible/roles/rabbitmq/tasks/upgrade.yml | 2 + .../roles/rabbitmq/tasks/version-check.yml | 59 +++++++++++++++++++ .../reference/message-queues/rabbitmq.rst | 3 +- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/rabbitmq/tasks/version-check.yml diff --git a/ansible/roles/rabbitmq/tasks/upgrade.yml b/ansible/roles/rabbitmq/tasks/upgrade.yml index 58e5bde46a..55bda0f48a 100644 --- a/ansible/roles/rabbitmq/tasks/upgrade.yml +++ b/ansible/roles/rabbitmq/tasks/upgrade.yml @@ -1,4 +1,6 @@ --- +- import_tasks: version-check.yml + - include_tasks: remove-ha-all-policy.yml when: - not om_enable_rabbitmq_high_availability | bool diff --git a/ansible/roles/rabbitmq/tasks/version-check.yml b/ansible/roles/rabbitmq/tasks/version-check.yml new file mode 100644 index 0000000000..25d196202f --- /dev/null +++ b/ansible/roles/rabbitmq/tasks/version-check.yml @@ -0,0 +1,59 @@ +--- +- block: + - name: Get current RabbitMQ version + vars: + service_name: "rabbitmq" + service: "{{ rabbitmq_services[service_name] }}" + become: true + command: "{{ kolla_container_engine }} exec {{ service.container_name }} rabbitmqctl --version" + register: rabbitmq_version_current + changed_when: false + + - name: Get new RabbitMQ version + become: true + vars: + rabbitmq_container: "{{ rabbitmq_services['rabbitmq'] }}" + kolla_container: + action: "start_container" + command: "rabbitmqctl --version" + detach: false + environment: + KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" + image: "{{ rabbitmq_container.image }}" + name: "rabbitmq_version_check" + restart_policy: oneshot + volumes: "{{ rabbitmq_default_volumes + rabbitmq_extra_volumes }}" + register: rabbitmq_version_new + failed_when: false + check_mode: false + + # As an example, when the new RabbitMQ version is 3.13.6: + # new_major_version = 3 + # new_minor_version = 13 + # new_version = 3.13 + # And if the current RabbitMQ version is 3.11.28: + # upgrade_version = 3.12 + - name: Check if running RabbitMQ is at most one version behind + vars: + current_version_major: "{{ rabbitmq_version_current.stdout | regex_search('^[0-9]+') }}" + current_version_minor: "{{ rabbitmq_version_current.stdout | regex_search('(?<=.)[^.].') }}" + current_version: "{{ rabbitmq_version_current.stdout | regex_replace('.[^.]+$', '') }}" + new_version_major: "{{ rabbitmq_version_new.stdout | regex_search('^[0-9]+') }}" + new_version_minor: "{{ rabbitmq_version_new.stdout | regex_search('(?<=.)[^.].') }}" + new_version: "{{ rabbitmq_version_new.stdout | regex_replace('.[^.]+$', '') }}" + # Note: this assumes 3.13 will be the last release before 4.0. + upgrade_version: "{{ '4.0' if current_version == '3.13' else current_version_major + '.' + (current_version_minor | int + 1) | string }}" + assert: + that: (current_version_major == new_version_major and + new_version_minor | int - current_version_minor | int <= 1) or + (new_version | float == 4.0 and current_version | float == 3.13) + fail_msg: > + Looks like you're trying to run a skip-release upgrade! + RabbitMQ must be at most one version behind the target release version ({{ rabbitmq_version_new.stdout | trim }}) to run this upgrade. + You are running {{ rabbitmq_version_current.stdout }}. + Please first upgrade to {{ upgrade_version }} with the command ``kolla-ansible rabbitmq-upgrade {{ upgrade_version }}``. + See these docs for more details: https://docs.openstack.org/kolla-ansible/latest/reference/message-queues/rabbitmq.html#slurp + + delegate_to: "{{ groups[role_rabbitmq_groups] | first }}" + run_once: true + tags: rabbitmq-version-check diff --git a/doc/source/reference/message-queues/rabbitmq.rst b/doc/source/reference/message-queues/rabbitmq.rst index ac56539526..e948613729 100644 --- a/doc/source/reference/message-queues/rabbitmq.rst +++ b/doc/source/reference/message-queues/rabbitmq.rst @@ -128,7 +128,8 @@ additional steps needed to migrate from transient to durable queues. .. warning:: Since the default changed from non-HA to Quorum queues in Bobcat release, - following procedure is required to be carried out before an upgrade. + following procedure is required to be carried out before a SLURP upgrade to + Caracal. 1. Stop all OpenStack services which use RabbitMQ, so that they will not attempt to recreate any queues yet.