diff --git a/ansible/roles/mariadb/tasks/recover_cluster.yml b/ansible/roles/mariadb/tasks/recover_cluster.yml index 92fcfdc1a3..ff07744eff 100644 --- a/ansible/roles/mariadb/tasks/recover_cluster.yml +++ b/ansible/roles/mariadb/tasks/recover_cluster.yml @@ -227,3 +227,5 @@ when: - bootstrap_host is defined - bootstrap_host != inventory_hostname + +- import_tasks: wait_for_loadbalancer.yml diff --git a/ansible/roles/mariadb/tasks/register.yml b/ansible/roles/mariadb/tasks/register.yml index 930305e955..b4b87d97f3 100644 --- a/ansible/roles/mariadb/tasks/register.yml +++ b/ansible/roles/mariadb/tasks/register.yml @@ -14,6 +14,8 @@ priv: "*.*:USAGE" run_once: True +- import_tasks: wait_for_loadbalancer.yml + - name: Creating the Mariabackup database become: true kolla_toolbox: diff --git a/ansible/roles/mariadb/tasks/wait_for_loadbalancer.yml b/ansible/roles/mariadb/tasks/wait_for_loadbalancer.yml new file mode 100644 index 0000000000..da6bd55c2e --- /dev/null +++ b/ansible/roles/mariadb/tasks/wait_for_loadbalancer.yml @@ -0,0 +1,16 @@ +--- +# Explicitly wait for the database to be accessible via the load balancer. +# Sometimes it can reject connections even when all database services are up, +# due to the health check polling in HAProxy. +- name: wait for MariaDB to be available via HAProxy + wait_for: + host: "{{ database_address }}" + port: "{{ database_port }}" + connect_timeout: 1 + timeout: 60 + search_regex: "MariaDB" + register: check_mariadb_port + until: check_mariadb_port is success + retries: 10 + delay: 6 + run_once: True