Skip to content

Commit 189b8cd

Browse files
seunghun1eeAlex-Welsh
authored andcommitted
Drop support for DB Loadbalancing with HAProxy + clustercheck
MariaDB Clustercheck has not been updated for a long time and ProxySQL has been working well as the default. Dropped DB Loadbalancing with HAProxy and MariaDB clustercheck support and ProxySQL now gets enabled automatically when MariaDB is enabled. Replaced MariaDB container healthcheck method with healthcheck.sh from official MariaDB docker images. Performing service upgrade with this patch will remove remaining mariadb_clustercheck container. Depends-on: https://review.opendev.org/c/openstack/kolla/+/962657 Change-Id: Ib655eae79ba73f4582b29fef82c2d882a474329b Signed-off-by: Seunghun Lee <[email protected]>
1 parent d9212c7 commit 189b8cd

File tree

14 files changed

+63
-90
lines changed

14 files changed

+63
-90
lines changed

ansible/group_vars/all/mariadb.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ mariadb_port: "{{ database_port }}"
1818
mariadb_wsrep_port: "4567"
1919
mariadb_ist_port: "4568"
2020
mariadb_sst_port: "4444"
21-
mariadb_clustercheck_port: "4569"
2221
mariadb_enable_tls_backend: "{{ database_enable_tls_backend }}"
2322

24-
mariadb_monitor_user: "{{ 'monitor' if enable_proxysql | bool else 'haproxy' }}"
23+
mariadb_monitor_user: "monitor"
2524

2625
mariadb_datadir_volume: "mariadb"
2726

@@ -30,8 +29,8 @@ mariadb_default_database_shard_hosts: "{% set default_shard = [] %}{% for host i
3029
mariadb_shard_id: "{{ mariadb_default_database_shard_id }}"
3130
mariadb_shard_name: "shard_{{ mariadb_shard_id }}"
3231
mariadb_shard_group: "mariadb_{{ mariadb_shard_name }}"
33-
mariadb_loadbalancer: "{{ 'proxysql' if enable_proxysql | bool else 'haproxy' }}"
34-
mariadb_backup_target: "{{ 'active' if mariadb_loadbalancer == 'haproxy' else 'replica' }}"
32+
mariadb_loadbalancer: proxysql
33+
mariadb_backup_target: replica
3534
mariadb_shard_root_user_prefix: "root_shard_"
3635
mariadb_shard_backup_user_prefix: "backup_shard_"
3736
mariadb_shards_info: "{{ groups['mariadb'] | database_shards_info() }}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
enable_proxysql: "yes"
2+
enable_proxysql: "{{ enable_mariadb }}"
33

44
proxysql_admin_port: "6032"

ansible/roles/mariadb/defaults/main.yml

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,7 @@ mariadb_services:
88
volumes: "{{ mariadb_default_volumes + mariadb_extra_volumes }}"
99
dimensions: "{{ mariadb_dimensions }}"
1010
healthcheck: "{{ mariadb_healthcheck }}"
11-
environment:
12-
MYSQL_USERNAME: "{{ mariadb_monitor_user }}"
13-
MYSQL_PASSWORD: "{% if enable_proxysql | bool %}{{ mariadb_monitor_password }}{% endif %}"
14-
MYSQL_HOST: "{{ api_interface_address }}"
15-
AVAILABLE_WHEN_DONOR: "1"
1611
haproxy:
17-
mariadb:
18-
enabled: "{{ enable_mariadb | bool and not enable_external_mariadb_load_balancer | bool }}"
19-
mode: "tcp"
20-
port: "{{ database_port }}"
21-
listen_port: "{{ mariadb_port }}"
22-
frontend_tcp_extra:
23-
- "option clitcpka"
24-
- "timeout client 3600s"
25-
backend_tcp_extra:
26-
- "option srvtcpka"
27-
- "timeout server 3600s"
28-
- "{% if enable_mariadb_clustercheck | bool %}option httpchk{% endif %}"
29-
custom_member_list: "{{ internal_haproxy_members.split(';') }}"
3012
mariadb_external_lb:
3113
enabled: "{{ enable_external_mariadb_load_balancer | bool }}"
3214
mode: "tcp"
@@ -39,18 +21,6 @@ mariadb_services:
3921
- "option srvtcpka"
4022
- "timeout server 3600s"
4123
custom_member_list: "{{ external_haproxy_members.split(';') }}"
42-
mariadb-clustercheck:
43-
container_name: mariadb_clustercheck
44-
group: "{{ mariadb_shard_group }}"
45-
enabled: "{{ enable_mariadb_clustercheck | bool }}"
46-
image: "{{ mariadb_clustercheck_image_full }}"
47-
volumes: "{{ mariadb_clustercheck_default_volumes + mariadb_clustercheck_extra_volumes }}"
48-
dimensions: "{{ mariadb_clustercheck_dimensions }}"
49-
environment:
50-
MYSQL_USERNAME: "{{ mariadb_monitor_user }}"
51-
MYSQL_PASSWORD: "{% if enable_proxysql | bool %}{{ mariadb_monitor_password }}{% endif %}"
52-
MYSQL_HOST: "{{ api_interface_address }}"
53-
AVAILABLE_WHEN_DONOR: "1"
5424

5525
####################
5626
# Database
@@ -61,8 +31,7 @@ database_max_timeout: 120
6131
####################
6232
# HAProxy
6333
####################
64-
internal_haproxy_members: "{% for host in mariadb_default_database_shard_hosts %} server {{ hostvars[host].ansible_facts.hostname }} {{ 'api' | kolla_address(host) }}:{{ mariadb_port }} check port {% if enable_mariadb_clustercheck | bool %}{{ mariadb_clustercheck_port }}{% else %}{{ mariadb_port }}{% endif %} inter 2000 rise 2 fall 5{% if not loop.first %} backup{% endif %};{% endfor %}"
65-
external_haproxy_members: "{% for host in mariadb_default_database_shard_hosts %} server {{ host }} {{ host }}:{{ mariadb_port }} check port {% if enable_mariadb_clustercheck | bool %}{{ mariadb_clustercheck_port }}{% else %}{{ mariadb_port }}{% endif %} inter 2000 rise 2 fall 5{% if not loop.first %} backup{% endif %};{% endfor %}"
34+
external_haproxy_members: "{% for host in mariadb_default_database_shard_hosts %} server {{ host }} {{ host }}:{{ mariadb_port }} check port {{ mariadb_port }} inter 2000 rise 2 fall 5{% if not loop.first %} backup{% endif %};{% endfor %}"
6635

6736
####################
6837
# Docker
@@ -71,33 +40,23 @@ mariadb_image: "{{ docker_image_url }}mariadb-server"
7140
mariadb_tag: "{{ openstack_tag }}"
7241
mariadb_image_full: "{{ mariadb_image }}:{{ mariadb_tag }}"
7342

74-
mariadb_clustercheck_image: "{{ docker_image_url }}mariadb-clustercheck"
75-
mariadb_clustercheck_tag: "{{ mariadb_tag }}"
76-
mariadb_clustercheck_image_full: "{{ mariadb_clustercheck_image }}:{{ mariadb_clustercheck_tag }}"
77-
7843
mariadb_dimensions: "{{ default_container_dimensions }}"
79-
mariadb_clustercheck_dimensions: "{{ default_container_dimensions }}"
8044

8145
mariadb_default_volumes:
8246
- "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
8347
- "/etc/localtime:/etc/localtime:ro"
8448
- "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
8549
- "{{ mariadb_datadir_volume }}:/var/lib/mysql"
8650
- "kolla_logs:/var/log/kolla/"
87-
mariadb_clustercheck_default_volumes:
88-
- "{{ node_config_directory }}/mariadb-clustercheck/:{{ container_config_directory }}/:ro"
89-
- "/etc/localtime:/etc/localtime:ro"
90-
- "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
91-
- "kolla_logs:/var/log/kolla/"
9251

9352
mariadb_extra_volumes: "{{ default_extra_volumes }}"
94-
mariadb_clustercheck_extra_volumes: "{{ default_extra_volumes }}"
9553

9654
mariadb_enable_healthchecks: "{{ enable_container_healthchecks }}"
9755
mariadb_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
9856
mariadb_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
9957
mariadb_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
100-
mariadb_healthcheck_test: ["CMD-SHELL", "/usr/bin/clustercheck"]
58+
mariadb_healthcheck_test: ["CMD-SHELL", "/usr/bin/healthcheck.sh --defaults-file /etc/{{ 'mysql/' if kolla_base_distro in ['ubuntu', 'debian'] else '' }}healthcheck.cnf --connect --galera_online"]
59+
10160
mariadb_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
10261
mariadb_healthcheck:
10362
interval: "{{ mariadb_healthcheck_interval }}"
@@ -122,19 +81,14 @@ mariadb_wsrep_extra_provider_options: []
12281
####################
12382
mariadb_backup_host: "{{ groups[mariadb_shard_group][0] }}"
12483
mariadb_backup_database_schema: "mysql"
125-
mariadb_backup_database_user: "{% if mariadb_loadbalancer == 'haproxy' %}backup{% else %}{{ mariadb_shard_backup_user_prefix }}{{ mariadb_shard_id | string }}{% endif %}"
84+
mariadb_backup_database_user: "{{ mariadb_shard_backup_user_prefix }}{{ mariadb_shard_id | string }}"
12685
mariadb_backup_type: "full"
127-
mariadb_backup_possible: "{{ mariadb_loadbalancer != 'haproxy' or inventory_hostname in mariadb_default_database_shard_hosts }}"
128-
129-
####################
130-
# Clustercheck
131-
####################
132-
enable_mariadb_clustercheck: "{{ 'True' if mariadb_loadbalancer == 'haproxy' else 'False' }}"
86+
mariadb_backup_possible: "{{ inventory_hostname in mariadb_default_database_shard_hosts }}"
13387

13488
####################
13589
# Sharding
13690
####################
137-
mariadb_shard_database_user: "{% if mariadb_loadbalancer == 'haproxy' %}{{ database_user }}{% else %}{{ mariadb_shard_root_user_prefix }}{{ mariadb_shard_id | string }}{% endif %}"
91+
mariadb_shard_database_user: "{{ mariadb_shard_root_user_prefix }}{{ mariadb_shard_id | string }}"
13892
mariadb_database_shard: "{{ mariadb_shards_info }}"
13993

14094
# Database

ansible/roles/mariadb/handlers/main.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,3 @@
7272
- groups[mariadb_shard_group + '_port_alive_False'] is defined
7373
- inventory_hostname in groups[mariadb_shard_group + '_port_alive_False']
7474
listen: Restart mariadb container
75-
76-
- name: Restart mariadb-clustercheck container
77-
vars:
78-
service_name: "mariadb-clustercheck"
79-
service: "{{ mariadb_services[service_name] }}"
80-
become: true
81-
kolla_container:
82-
action: "recreate_or_restart_container"
83-
common_options: "{{ docker_common_options }}"
84-
image: "{{ service.image }}"
85-
name: "{{ service.container_name }}"
86-
volumes: "{{ service.volumes }}"
87-
dimensions: "{{ service.dimensions }}"
88-
environment: "{{ service.environment }}"
89-
when:
90-
- service | service_enabled_and_mapped_to_host

ansible/roles/mariadb/tasks/config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@
7070
become: true
7171
when: service | service_enabled_and_mapped_to_host
7272

73+
- name: Copying over healthcheck.cnf
74+
vars:
75+
service_name: "mariadb"
76+
service: "{{ mariadb_services[service_name] }}"
77+
merge_configs:
78+
sources:
79+
- "{{ role_path }}/templates/healthcheck.cnf.j2"
80+
- "{{ node_custom_config }}/healthcheck.cnf"
81+
- "{{ node_custom_config }}/mariadb/{{ inventory_hostname }}/healthcheck.cnf"
82+
dest: "{{ node_config_directory }}/{{ service_name }}/healthcheck.cnf"
83+
mode: "0660"
84+
become: true
85+
when:
86+
- mariadb_enable_healthchecks | bool
87+
- service | service_enabled_and_mapped_to_host
88+
7389
- include_tasks: copy-certs.yml
7490
when:
7591
- mariadb_copy_certs | bool

ansible/roles/mariadb/tasks/loadbalancer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
login_user: "{{ database_user }}"
3131
login_password: "{{ database_password }}"
3232
name: "{{ mariadb_monitor_user }}"
33-
password: "{% if enable_proxysql | bool %}{{ mariadb_monitor_password }}{% endif %}"
33+
password: "{{ mariadb_monitor_password }}"
3434
host: "%"
3535
priv: "*.*:USAGE,REPLICATION CLIENT"
3636
tags: always

ansible/roles/mariadb/tasks/register.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
login_user: "{{ database_user }}"
3030
login_password: "{{ database_password }}"
3131
name: "{{ mariadb_monitor_user }}"
32-
password: "{% if enable_proxysql | bool %}{{ mariadb_monitor_password }}{% endif %}"
32+
password: "{{ mariadb_monitor_password }}"
3333
host: "%"
3434
priv: "*.*:USAGE,REPLICATION CLIENT"
3535
when:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
---
22
- import_tasks: deploy.yml
3+
4+
# TODO(seunghun1ee): Remove this task after 2026.1
5+
- name: "Stop and remove mariadb_clustercheck containers"
6+
become: true
7+
kolla_container:
8+
action: "stop_and_remove_container"
9+
common_options: "{{ docker_common_options }}"
10+
name: "mariadb_clustercheck"
11+
ignore_missing: true
12+
when:
13+
- "'mariadb_clustercheck' not in skip_stop_containers"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[mariadb-client]
2+
user={{ mariadb_monitor_user }}
3+
password={{ mariadb_monitor_password }}

ansible/roles/mariadb/templates/mariadb-clustercheck.json.j2

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)