The galera cluster rely on WSREP for cluster consistency. While the default MySQL monitor will allow us to know when the database node is minimally functional it does not provide the ability to query the node state allowing loadbalancers, operators, and deployers to know a node is healthy prior to being allowed to accept connections. This change implements the checkcluster script as provided by the fine folks at Percona. The implementation of this check follows the guild-lines noted here [0]. With this in-place, we'll be able to convert our haproxy check for the galera cluster nodes to use an HTTP check on port 9200 instead of the default MySQL login which will provide for a more robust and fault tolerant cluster. [0] https://www.percona.com/doc/percona-xtradb-cluster/LATEST/howtos/virt_sandbox.html Closes-Bug: #1665667 Change-Id: Ie1b3b9724dd33de1d90634166e585ecceb1f4c96 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
86 lines
2.8 KiB
YAML
86 lines
2.8 KiB
YAML
---
|
|
# Copyright 2016, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Run functional tests
|
|
hosts: galera_all
|
|
user: root
|
|
gather_facts: true
|
|
tasks:
|
|
- name: Check cluster incoming addresses
|
|
command: |
|
|
mysql -h {{ ansible_host }} \
|
|
-p"{{ galera_root_password }}" \
|
|
-e "show status like 'wsrep_incoming_addresses';" \
|
|
--silent \
|
|
--skip-column-names
|
|
register: wsrep_incoming_addresses
|
|
changed_when: false
|
|
tags:
|
|
- skip_ansible_lint
|
|
- name: Check cluster local state
|
|
command: |
|
|
mysql -h {{ ansible_host }} \
|
|
-p"{{ galera_root_password }}" \
|
|
-e "show status like 'wsrep_local_state_comment';" \
|
|
--silent \
|
|
--skip-column-names
|
|
register: wsrep_local_state_comment
|
|
changed_when: false
|
|
tags:
|
|
- skip_ansible_lint
|
|
- name: Check cluster evs state
|
|
command: |
|
|
mysql -h {{ ansible_host }} \
|
|
-p"{{ galera_root_password }}" \
|
|
-e "show status like 'wsrep_evs_state';" \
|
|
--silent \
|
|
--skip-column-names
|
|
register: wsrep_evs_state
|
|
changed_when: false
|
|
tags:
|
|
- skip_ansible_lint
|
|
- name: Check contents
|
|
assert:
|
|
that:
|
|
- "'Synced' in wsrep_local_state_comment.stdout"
|
|
- "'OPERATIONAL' in wsrep_evs_state.stdout"
|
|
- "'10.1.0.2' in wsrep_incoming_addresses.stdout"
|
|
- "'10.1.0.3' in wsrep_incoming_addresses.stdout"
|
|
- "'10.1.0.4' in wsrep_incoming_addresses.stdout"
|
|
- name: Create DB for service on 10.1.0.2
|
|
mysql_db:
|
|
login_user: "{{ galera_root_user }}"
|
|
login_password: "{{ galera_root_password }}"
|
|
login_host: "10.1.0.2"
|
|
name: "OSA-test"
|
|
state: "present"
|
|
when: ansible_host == '10.1.0.2'
|
|
- name: Grant access to the DB on 10.1.0.3
|
|
mysql_user:
|
|
login_user: "{{ galera_root_user }}"
|
|
login_password: "{{ galera_root_password }}"
|
|
login_host: "10.1.0.3"
|
|
name: "osa-tester"
|
|
password: "tester-secrete"
|
|
host: "{{ item }}"
|
|
state: "present"
|
|
priv: "OSA-test.*:ALL"
|
|
with_items:
|
|
- "localhost"
|
|
- "%"
|
|
when: ansible_host == '10.1.0.3'
|
|
vars_files:
|
|
- common/test-vars.yml
|