Skip to content

Commit

Permalink
Wait for MariaDB to be accessible via HAProxy
Browse files Browse the repository at this point in the history
Explicitly wait for the database to be accessible via the load balancer.
Sometimes it can reject connections even when all database services are up,
possibly due to the health check polling in HAProxy.

Closes-Bug: #1840145
Change-Id: I7601bb710097a78f6b29bc4018c71f2c6283eef2
  • Loading branch information
ssolkhon committed Aug 15, 2019
1 parent 41e634e commit 03cd7eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ansible/roles/mariadb/tasks/recover_cluster.yml
Expand Up @@ -190,3 +190,5 @@
when:
- bootstrap_host is defined
- bootstrap_host != inventory_hostname

- import_tasks: wait_for_loadbalancer.yml
2 changes: 2 additions & 0 deletions ansible/roles/mariadb/tasks/register.yml
Expand Up @@ -13,6 +13,8 @@
priv: "*.*:USAGE"
run_once: True

- import_tasks: wait_for_loadbalancer.yml

- name: Creating the Percona XtraBackup database
kolla_toolbox:
module_name: mysql_db
Expand Down
16 changes: 16 additions & 0 deletions 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

0 comments on commit 03cd7eb

Please sign in to comment.