Merge "Refactor MariaDB and RabbitMQ restart procedure"

This commit is contained in:
Zuul 2023-06-20 06:12:49 +00:00 committed by Gerrit Code Review
commit d5bfc5a05c
17 changed files with 246 additions and 132 deletions

72
ansible/mariadb.yml Normal file
View File

@ -0,0 +1,72 @@
---
# For MariaDB we need to be careful about restarting services, to avoid losing quorum.
- name: Apply role mariadb
gather_facts: false
hosts:
- mariadb
- '&enable_mariadb_True'
tags:
- mariadb
tasks:
- import_role:
name: mariadb
- name: Restart mariadb services
gather_facts: false
hosts:
- mariadb_restart
- '&enable_mariadb_True'
# Restart in batches
serial: "33%"
tags:
- mariadb
tasks:
- import_role:
name: mariadb
tasks_from: restart_services.yml
- name: Start mariadb services
gather_facts: false
hosts:
- mariadb_start
- '&enable_mariadb_True'
# Start in batches
serial: "33%"
tags:
- mariadb
tasks:
- import_role:
name: mariadb
tasks_from: restart_services.yml
- name: Restart bootstrap mariadb service
gather_facts: false
hosts:
- mariadb_bootstrap_restart
- '&enable_mariadb_True'
tags:
- mariadb
tasks:
- import_role:
name: mariadb
tasks_from: restart_services.yml
- name: Apply mariadb post-configuration
gather_facts: false
hosts:
- mariadb
- '&enable_mariadb_True'
tags:
- mariadb
tasks:
- name: Include mariadb post-deploy.yml
include_role:
name: mariadb
tasks_from: post-deploy.yml
when: kolla_action in ['deploy', 'reconfigure', 'upgrade']
- name: Include mariadb post-upgrade.yml
include_role:
name: mariadb
tasks_from: post-upgrade.yml
when: kolla_action == 'upgrade'

115
ansible/rabbitmq.yml Normal file
View File

@ -0,0 +1,115 @@
---
# For RabbitMQ we need to be careful about restarting services, to avoid losing quorum.
- name: Apply role rabbitmq
gather_facts: false
hosts:
- rabbitmq
- '&enable_rabbitmq_True'
tags:
- rabbitmq
tasks:
- import_role:
name: rabbitmq
vars:
role_rabbitmq_cluster_cookie: '{{ rabbitmq_cluster_cookie }}'
role_rabbitmq_cluster_port: '{{ rabbitmq_cluster_port }}'
role_rabbitmq_epmd_port: '{{ rabbitmq_epmd_port }}'
role_rabbitmq_groups: rabbitmq
role_rabbitmq_management_port: '{{ rabbitmq_management_port }}'
role_rabbitmq_monitoring_password: '{{ rabbitmq_monitoring_password }}'
role_rabbitmq_monitoring_user: '{{ rabbitmq_monitoring_user }}'
role_rabbitmq_password: '{{ rabbitmq_password }}'
role_rabbitmq_port: '{{ rabbitmq_port }}'
role_rabbitmq_prometheus_port: '{{ rabbitmq_prometheus_port }}'
role_rabbitmq_user: '{{ rabbitmq_user }}'
- name: Restart rabbitmq services
gather_facts: false
hosts:
- rabbitmq_restart
- '&enable_rabbitmq_True'
# Restart in batches
serial: "33%"
tags:
- rabbitmq
tasks:
- import_role:
name: rabbitmq
tasks_from: restart_services.yml
vars:
role_rabbitmq_cluster_cookie: '{{ rabbitmq_cluster_cookie }}'
role_rabbitmq_groups: rabbitmq
- name: Apply rabbitmq post-configuration
gather_facts: false
hosts:
- rabbitmq
- '&enable_rabbitmq_True'
tags:
- rabbitmq
tasks:
- name: Include rabbitmq post-deploy.yml
include_role:
name: rabbitmq
tasks_from: post-deploy.yml
when: kolla_action in ['deploy', 'reconfigure']
vars:
role_rabbitmq_cluster_cookie: '{{ rabbitmq_cluster_cookie }}'
role_rabbitmq_groups: rabbitmq
- name: Apply role rabbitmq (outward)
gather_facts: false
hosts:
- outward-rabbitmq
- '&enable_outward_rabbitmq_True'
tags:
- rabbitmq
tasks:
- import_role:
name: rabbitmq
vars:
project_name: outward_rabbitmq
role_rabbitmq_cluster_cookie: '{{ outward_rabbitmq_cluster_cookie }}'
role_rabbitmq_cluster_port: '{{ outward_rabbitmq_cluster_port }}'
role_rabbitmq_epmd_port: '{{ outward_rabbitmq_epmd_port }}'
role_rabbitmq_groups: outward-rabbitmq
role_rabbitmq_management_port: '{{ outward_rabbitmq_management_port }}'
role_rabbitmq_password: '{{ outward_rabbitmq_password }}'
role_rabbitmq_port: '{{ outward_rabbitmq_port }}'
role_rabbitmq_prometheus_port: '{{ outward_rabbitmq_prometheus_port }}'
role_rabbitmq_user: '{{ outward_rabbitmq_user }}'
- name: Restart rabbitmq (outward) services
gather_facts: false
hosts:
- outward_rabbitmq_restart
- '&enable_outward_rabbitmq_True'
# Restart in batches
serial: "33%"
tags:
- rabbitmq
tasks:
- import_role:
name: rabbitmq
tasks_from: restart_services.yml
vars:
project_name: outward_rabbitmq
role_rabbitmq_cluster_cookie: '{{ outward_rabbitmq_cluster_cookie }}'
role_rabbitmq_groups: outward-rabbitmq
- name: Apply rabbitmq (outward) post-configuration
gather_facts: false
hosts:
- outward-rabbitmq
- '&enable_outward_rabbitmq_True'
tags:
- rabbitmq
tasks:
- name: Include rabbitmq (outward) post-deploy.yml
include_role:
name: rabbitmq
when: kolla_action in ['deploy', 'reconfigure']
vars:
project_name: outward_rabbitmq
role_rabbitmq_cluster_cookie: '{{ outward_rabbitmq_cluster_cookie }}'
role_rabbitmq_groups: outward-rabbitmq

View File

@ -48,38 +48,29 @@
no_log: true
listen: Bootstrap MariaDB cluster
- name: Ensure MariaDB is running normally on bootstrap host
group_by:
key: mariadb_bootstrap_restart
listen: Bootstrap MariaDB cluster
- name: Restart MariaDB on existing cluster members
include_tasks: 'restart_services.yml'
group_by:
key: mariadb_restart
when:
- groups[mariadb_shard_group + '_port_alive_True'] is defined
- inventory_hostname in groups[mariadb_shard_group + '_port_alive_True']
- groups[mariadb_shard_group + '_port_alive_True'].index(inventory_hostname) % 4 == item
- kolla_action != "config"
listen: restart mariadb
loop:
- 0
- 1
- 2
- 3
- name: Start MariaDB on new nodes
include_tasks: 'restart_services.yml'
group_by:
key: mariadb_start
when:
- bootstrap_host is not defined or bootstrap_host != inventory_hostname
- groups[mariadb_shard_group + '_port_alive_False'] is defined
- inventory_hostname in groups[mariadb_shard_group + '_port_alive_False']
- groups[mariadb_shard_group + '_port_alive_False'].index(inventory_hostname) % 4 == item
- kolla_action != "config"
listen: restart mariadb
loop:
- 0
- 1
- 2
- 3
- name: Ensure MariaDB is running normally on bootstrap host
include_tasks: 'restart_services.yml'
listen: Bootstrap MariaDB cluster
- name: Restart mariadb-clustercheck container
vars:

View File

@ -4,10 +4,3 @@
- import_tasks: check-containers.yml
- import_tasks: bootstrap.yml
- name: Flush handlers
meta: flush_handlers
- import_tasks: register.yml
- import_tasks: check.yml

View File

@ -0,0 +1,4 @@
---
- import_tasks: register.yml
- import_tasks: check.yml

View File

@ -0,0 +1,24 @@
---
- name: Run upgrade in MariaDB container
vars:
service_name: "mariadb"
service: "{{ mariadb_services[service_name] }}"
become: true
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
detach: False
dimensions: "{{ service.dimensions }}"
environment:
KOLLA_UPGRADE:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
DB_HOST: "{{ api_interface_address }}"
DB_PORT: "{{ mariadb_port }}"
DB_ROOT_PASSWORD: "{{ database_password }}"
image: "{{ service.image }}"
labels:
UPGRADE:
name: "upgrade_mariadb"
restart_policy: no
volumes: "{{ service.volumes }}"
no_log: true

View File

@ -1,26 +1,2 @@
---
- import_tasks: deploy.yml
- name: Run upgrade in MariaDB container
vars:
service_name: "mariadb"
service: "{{ mariadb_services[service_name] }}"
become: true
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
detach: False
dimensions: "{{ service.dimensions }}"
environment:
KOLLA_UPGRADE:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
DB_HOST: "{{ api_interface_address }}"
DB_PORT: "{{ mariadb_port }}"
DB_ROOT_PASSWORD: "{{ database_password }}"
image: "{{ service.image }}"
labels:
UPGRADE:
name: "upgrade_mariadb"
restart_policy: no
volumes: "{{ service.volumes }}"
no_log: true

View File

@ -2,7 +2,7 @@
docker_version_min: '18.09'
docker_py_version_min: '3.4.1'
ansible_version_min: '2.13'
ansible_version_max: '2.14.2'
ansible_version_max: '2.14'
# Top level keys should match ansible_facts.distribution.
# These map to lists of supported releases (ansible_facts.distribution_release) or

View File

@ -1,26 +1,6 @@
---
# NOTE(mgoddard): These tasks perform a 'full stop upgrade', which is necessary when moving between
# major releases. In future kolla-ansible releases we may be able to change this to a rolling
# restart. For info on this process see https://www.rabbitmq.com/upgrade.html
- name: Restart first rabbitmq container
vars:
service_name: "rabbitmq"
service: "{{ rabbitmq_services[service_name] }}"
include_tasks: 'restart_services.yml'
- name: Restart rabbitmq container
group_by:
key: "{{ project_name }}_restart"
when:
- kolla_action != "config"
- inventory_hostname == groups[service.group] | first
listen: Restart rabbitmq container
- name: Restart remaining rabbitmq containers
vars:
service_name: "rabbitmq"
service: "{{ rabbitmq_services[service_name] }}"
include_tasks: 'restart_services.yml'
when:
- kolla_action != "config"
- inventory_hostname == item
- inventory_hostname != groups[service.group] | first
loop: "{{ groups[service.group] }}"
listen: Restart rabbitmq container

View File

@ -8,8 +8,3 @@
- import_tasks: check-containers.yml
- import_tasks: bootstrap.yml
- name: Flush handlers
meta: flush_handlers
- import_tasks: feature-flags.yml

View File

@ -0,0 +1,2 @@
---
- import_tasks: feature-flags.yml

View File

@ -8,6 +8,3 @@
- import_tasks: feature-flags.yml
- import_tasks: check-containers.yml
- name: Flush handlers
meta: flush_handlers

View File

@ -380,14 +380,9 @@
- { role: redis,
tags: redis }
- name: Apply role mariadb
gather_facts: false
hosts:
- mariadb
- '&enable_mariadb_True'
roles:
- { role: mariadb,
tags: mariadb }
# MariaDB deployment is more complicated than other services, so is covered in
# its own playbook.
- import_playbook: mariadb.yml
- name: Apply role memcached
gather_facts: false
@ -440,44 +435,7 @@
- { role: multipathd,
tags: multipathd }
- name: Apply role rabbitmq
gather_facts: false
hosts:
- rabbitmq
- '&enable_rabbitmq_True'
roles:
- { role: rabbitmq,
tags: rabbitmq,
role_rabbitmq_cluster_cookie: '{{ rabbitmq_cluster_cookie }}',
role_rabbitmq_cluster_port: '{{ rabbitmq_cluster_port }}',
role_rabbitmq_epmd_port: '{{ rabbitmq_epmd_port }}',
role_rabbitmq_groups: rabbitmq,
role_rabbitmq_management_port: '{{ rabbitmq_management_port }}',
role_rabbitmq_monitoring_password: '{{ rabbitmq_monitoring_password }}',
role_rabbitmq_monitoring_user: '{{ rabbitmq_monitoring_user }}',
role_rabbitmq_password: '{{ rabbitmq_password }}',
role_rabbitmq_port: '{{ rabbitmq_port }}',
role_rabbitmq_prometheus_port: '{{ rabbitmq_prometheus_port }}',
role_rabbitmq_user: '{{ rabbitmq_user }}' }
- name: Apply role rabbitmq (outward)
gather_facts: false
hosts:
- outward-rabbitmq
- '&enable_outward_rabbitmq_True'
roles:
- { role: rabbitmq,
tags: rabbitmq,
project_name: outward_rabbitmq,
role_rabbitmq_cluster_cookie: '{{ outward_rabbitmq_cluster_cookie }}',
role_rabbitmq_cluster_port: '{{ outward_rabbitmq_cluster_port }}',
role_rabbitmq_epmd_port: '{{ outward_rabbitmq_epmd_port }}',
role_rabbitmq_groups: outward-rabbitmq,
role_rabbitmq_management_port: '{{ outward_rabbitmq_management_port }}',
role_rabbitmq_password: '{{ outward_rabbitmq_password }}',
role_rabbitmq_port: '{{ outward_rabbitmq_port }}',
role_rabbitmq_prometheus_port: '{{ outward_rabbitmq_prometheus_port }}',
role_rabbitmq_user: '{{ outward_rabbitmq_user }}' }
- import_playbook: rabbitmq.yml
- name: Apply role etcd
gather_facts: false

View File

@ -90,12 +90,10 @@ Install dependencies for the virtual environment
pip install -U pip
#. Install `Ansible <http://www.ansible.com>`__. Kolla Ansible requires at least
Ansible ``6`` and supports up to ``7``. Ansible-core must not be greater
than 2.14.2 due to a regression.
Ansible ``6`` and supports up to ``7``.
.. code-block:: console
pip install 'ansible-core>=2.13,<=2.14.2'
pip install 'ansible>=6,<8'

View File

@ -26,7 +26,6 @@ python virtual environment on the Ansible control host. For example:
source /path/to/venv/bin/activate
pip install -U pip
pip install kolla-ansible
pip install 'ansible-core>=2.13,<=2.14.2'
pip install 'ansible>=6,<8'
deactivate

View File

@ -0,0 +1,10 @@
---
upgrade:
- |
Removes the restriction on the maximum supported version of 2.14.2 for
``ansible-core``. Any 2.14 series release is now supported.
other:
- |
Refactors the MariaDB and RabbitMQ restart procedures to be compatible with
Ansible 2.14.3+. See `Ansible issue 80848
<https://github.com/ansible/ansible/issues/80848>`__ for details.

View File

@ -245,7 +245,7 @@
- name: install kolla-ansible and dependencies
vars:
ansible_core_version_min: "==2.13.*"
ansible_core_version_max: "==2.14.2"
ansible_core_version_max: "==2.14.*"
# Test latest ansible version on Ubuntu, minimum supported on others.
ansible_core_version_constraint: >-
{{ ansible_core_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_core_version_max }}