Files
openstack-ansible-rabbitmq_…/tasks/rabbitmq_feature_flags.yml
Dmitriy Rabotyagov 1a9074c590 Ensure no CQ mirroring policies applied
During migration to Quorum queues we have renamed vhosts
to not contain leading slash for them. However, some services
at the same time were configured not to have RPC messaging,
but only notifications whenever needed - like keystone, glance, etc.

This left such vhosts still containing HA policy on them, leading
to RabbitMQ upgrade failures with:
```
rabbitmq-server[2934794]: Application rabbit exited with reason:
{{failed_to_deny_deprecated_features,[classic_queue_mirroring]},{rabbit,start,[normal,[]]}}
```

This patch implements a check of deprecated feature flags and
disables all HA policies across the board before upgrade happens.

As we don't want to force removal when running RabbitMQ 3.13,
the removal is enforced only during upgrade to 4.0.
Conditions are maintained on a task level rather then a block
to make it extendable with other deprecated flags in the future.

Change-Id: I372421e0347687a1d861b548fd20ee92b150c301
Signed-off-by: Dmitriy Rabotyagov <dmitriy.rabotyagov@cleura.com>
2025-08-26 15:12:14 +00:00

54 lines
2.2 KiB
YAML

---
# Copyright 2024, BBC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: "Check for disabled RabbitMQ feature flags"
ansible.builtin.command: "rabbitmqctl list_feature_flags --formatter json name state stability"
register: _feature_flags
changed_when: false
failed_when: false
# NOTE: changed_when required despite the above check because 'unstable'
# feature flags will remain disabled each time this runs
- name: "Enable missing RabbitMQ feature flags"
ansible.builtin.command: "rabbitmqctl enable_feature_flag {{ flag['name'] }}"
changed_when: false
loop: "{{ _feature_flags.stdout | from_json | rejectattr('stability', 'eq', 'experimental') | selectattr('state', 'eq', 'disabled') }}"
loop_control:
loop_var: flag
- name: Check for deprecated features
when:
- rabbitmq_upgrade | bool
tags:
- rabbitmq-upgrade
block:
- name: Check for deprecated features
ansible.builtin.command: rabbitmq-diagnostics check_if_any_deprecated_features_are_used --formatter json
changed_when: false
failed_when: false
register: deprecated_features
- name: Disable classic queues if still used
vars:
parsed_deprecations: "{{ ((deprecated_features.rc == 0) | ternary(deprecated_features.stdout, deprecated_features.stderr)) | from_json }}"
ansible.builtin.command: rabbitmqctl remove_classic_queue_mirroring_from_policies
changed_when: true
when:
- rabbitmq_package_version is version('4.0', '>=')
- installed_rabbitmq.rc == 0
- installed_rabbitmq.stdout is version('4.0', '<')
- parsed_deprecations.result == 'error'
- "'classic_queue_mirroring' in parsed_deprecations.deprecated_features"