From 8f0a4bcb0d60f98af591b5c87e774826ac2c63fd Mon Sep 17 00:00:00 2001 From: Michal Arbet Date: Tue, 19 Mar 2024 23:42:16 +0100 Subject: [PATCH] Switch mariadb's loadbalancer from HAProxy to ProxySQL It's been some time since ProxySQL has been with us in Kolla. Let's switch the load balancer for MariaDB connections from HAProxy to ProxySQL. Depends-On: https://review.opendev.org/c/openstack/kolla/+/928956 Change-Id: I42ba4fb83b5bb31058e888f0d39d47c27b844de5 --- ansible/group_vars/all.yml | 3 ++- ansible/roles/mariadb/defaults/main.yml | 2 +- ansible/roles/mariadb/handlers/main.yml | 1 + ansible/roles/mariadb/tasks/backup.yml | 4 +++- ansible/roles/mariadb/tasks/recover_cluster.yml | 4 ++-- etc/kolla/globals.yml | 2 +- .../switch-to-proxysql-907c2bc2f2c04de4.yaml | 15 +++++++++++++++ tests/setup_gate.sh | 8 ++++---- 8 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/switch-to-proxysql-907c2bc2f2c04de4.yaml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index ba0d9d7ceb..a212005d83 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -549,6 +549,7 @@ mariadb_shard_id: "{{ mariadb_default_database_shard_id }}" mariadb_shard_name: "shard_{{ mariadb_shard_id }}" mariadb_shard_group: "mariadb_{{ mariadb_shard_name }}" mariadb_loadbalancer: "{{ 'proxysql' if enable_proxysql | bool else 'haproxy' }}" +mariadb_backup_target: "{{ 'active' if mariadb_loadbalancer == 'haproxy' else 'replica' }}" mariadb_shard_root_user_prefix: "root_shard_" mariadb_shard_backup_user_prefix: "backup_shard_" mariadb_shards_info: "{{ groups['mariadb'] | database_shards_info() }}" @@ -937,7 +938,7 @@ enable_ovs_dpdk: "no" enable_osprofiler: "no" enable_placement: "{{ enable_nova | bool or enable_zun | bool }}" enable_prometheus: "no" -enable_proxysql: "no" +enable_proxysql: "yes" enable_redis: "no" enable_skyline: "no" enable_swift: "no" diff --git a/ansible/roles/mariadb/defaults/main.yml b/ansible/roles/mariadb/defaults/main.yml index a1ac4fa312..49f2e43526 100644 --- a/ansible/roles/mariadb/defaults/main.yml +++ b/ansible/roles/mariadb/defaults/main.yml @@ -129,7 +129,7 @@ mariadb_backup_possible: "{{ mariadb_loadbalancer != 'haproxy' or inventory_host #################### # Clustercheck #################### -enable_mariadb_clustercheck: "{{ enable_haproxy }}" +enable_mariadb_clustercheck: "{{ 'True' if mariadb_loadbalancer == 'haproxy' else 'False' }}" #################### # Sharding diff --git a/ansible/roles/mariadb/handlers/main.yml b/ansible/roles/mariadb/handlers/main.yml index 708ba1bb2c..68422deed3 100644 --- a/ansible/roles/mariadb/handlers/main.yml +++ b/ansible/roles/mariadb/handlers/main.yml @@ -89,3 +89,4 @@ - restart mariadb-clustercheck when: - kolla_action != "config" + - service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/mariadb/tasks/backup.yml b/ansible/roles/mariadb/tasks/backup.yml index 4facbe92a2..1c25f9bac0 100644 --- a/ansible/roles/mariadb/tasks/backup.yml +++ b/ansible/roles/mariadb/tasks/backup.yml @@ -10,10 +10,12 @@ register: container_facts - name: Taking {{ mariadb_backup_type }} database backup via Mariabackup + vars: + cmd: "{{ 'kolla_mariadb_backup.sh' if mariadb_backup_target == 'active' else 'kolla_mariadb_backup_replica.sh' }}" become: true kolla_container: action: "start_container" - command: "bash -c 'sudo -E kolla_set_configs && /usr/local/bin/kolla_mariadb_backup.sh'" + command: "bash -c 'sudo -E kolla_set_configs && /usr/local/bin/{{ cmd }}'" common_options: "{{ docker_common_options }}" detach: False # NOTE(mgoddard): Try to use the same image as the MariaDB server container diff --git a/ansible/roles/mariadb/tasks/recover_cluster.yml b/ansible/roles/mariadb/tasks/recover_cluster.yml index e62a82fc17..9fcb488d99 100644 --- a/ansible/roles/mariadb/tasks/recover_cluster.yml +++ b/ansible/roles/mariadb/tasks/recover_cluster.yml @@ -180,7 +180,7 @@ dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment | default({}) }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - with_dict: "{{ mariadb_services }}" + with_dict: "{{ mariadb_services | select_services_enabled_and_mapped_to_host }}" when: - bootstrap_host is defined - bootstrap_host != inventory_hostname @@ -211,7 +211,7 @@ dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment | default({}) }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - with_dict: "{{ mariadb_services }}" + with_dict: "{{ mariadb_services | select_services_enabled_and_mapped_to_host }}" when: - bootstrap_host is defined - bootstrap_host == inventory_hostname diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 0eef2a3e3e..da7574eff6 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -411,7 +411,7 @@ workaround_ansible_issue_8743: yes #enable_osprofiler: "no" #enable_placement: "{{ enable_nova | bool or enable_zun | bool }}" #enable_prometheus: "no" -#enable_proxysql: "no" +#enable_proxysql: "yes" #enable_redis: "no" #enable_skyline: "no" #enable_swift: "no" diff --git a/releasenotes/notes/switch-to-proxysql-907c2bc2f2c04de4.yaml b/releasenotes/notes/switch-to-proxysql-907c2bc2f2c04de4.yaml new file mode 100644 index 0000000000..649ffd50fe --- /dev/null +++ b/releasenotes/notes/switch-to-proxysql-907c2bc2f2c04de4.yaml @@ -0,0 +1,15 @@ +--- +upgrade: + - | + The config option ``enable_proxysql`` has been changed to + ``yes``, which means that MySQL connections will now be + handled by ProxySQL by default instead of HAProxy. Users + who wish to retain load balancing of MySQL connections + through HAProxy must set ``enable_proxysql`` to ``no``. + Also Due to this change, the config option + ``enable_mariadb_clustercheck`` is also dynamically + changed to ``no``. Users who still wish to maintain + ``mariadb_clustercheck`` can override this config option + in the configuration. However, with ProxySQL, + ``mariadb_clustercheck`` is no longer needed and can be + manually removed. diff --git a/tests/setup_gate.sh b/tests/setup_gate.sh index c3115408e5..8b8b291352 100755 --- a/tests/setup_gate.sh +++ b/tests/setup_gate.sh @@ -13,7 +13,7 @@ function prepare_images { fi if [[ $SCENARIO != "bifrost" ]]; then - GATE_IMAGES="^cron,^fluentd,^glance,^haproxy,^keepalived,^keystone,^kolla-toolbox,^mariadb,^memcached,^neutron,^nova-,^openvswitch,^rabbitmq,^horizon,^heat,^placement" + GATE_IMAGES="^cron,^fluentd,^glance,^haproxy,^proxysql,^keepalived,^keystone,^kolla-toolbox,^mariadb,^memcached,^neutron,^nova-,^openvswitch,^rabbitmq,^horizon,^heat,^placement" else GATE_IMAGES="bifrost" fi @@ -58,7 +58,7 @@ function prepare_images { fi if [[ $SCENARIO == "mariadb" ]]; then - GATE_IMAGES="^cron,^fluentd,^haproxy,^keepalived,^kolla-toolbox,^mariadb" + GATE_IMAGES="^cron,^fluentd,^haproxy,^proxysql,^keepalived,^kolla-toolbox,^mariadb" fi if [[ $SCENARIO == "lets-encrypt" ]]; then @@ -66,11 +66,11 @@ function prepare_images { fi if [[ $SCENARIO == "prometheus-opensearch" ]]; then - GATE_IMAGES="^cron,^fluentd,^grafana,^haproxy,^keepalived,^kolla-toolbox,^mariadb,^memcached,^opensearch,^prometheus,^rabbitmq" + GATE_IMAGES="^cron,^fluentd,^grafana,^haproxy,^proxysql,^keepalived,^kolla-toolbox,^mariadb,^memcached,^opensearch,^prometheus,^rabbitmq" fi if [[ $SCENARIO == "venus" ]]; then - GATE_IMAGES="^cron,^opensearch,^fluentd,^haproxy,^keepalived,^keystone,^kolla-toolbox,^mariadb,^memcached,^rabbitmq,^venus" + GATE_IMAGES="^cron,^opensearch,^fluentd,^haproxy,^proxysql,^keepalived,^keystone,^kolla-toolbox,^mariadb,^memcached,^rabbitmq,^venus" fi if [[ $SCENARIO == "skyline" || $SCENARIO == "skyline-sso" ]]; then