Skip to content
Snippets Groups Projects
Commit 0f635266 authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review
Browse files

Merge "Cleanup mariadb and make compatiable with mesos"

parents 473022a7 7e2ce014
No related branches found
No related tags found
No related merge requests found
...@@ -11,20 +11,18 @@ ...@@ -11,20 +11,18 @@
always_run: True always_run: True
run_once: True run_once: True
# TODO(SamYaple): Improve failed_when check - name: Creating mariadb volume
- name: Checking if a previous cluster exists kolla_docker:
command: docker exec mariadb stat /var/lib/mysql/grastate.dat action: "create_volume"
register: exists common_options: "{{ docker_common_options }}"
changed_when: False name: "mariadb"
failed_when: False register: mariadb_volume
always_run: True
run_once: True
- name: Writing hostname of host with existing cluster files to temp file - name: Writing hostname of host with existing cluster files to temp file
local_action: copy content={{ ansible_hostname }} dest=/tmp/kolla_mariadb_cluster mode=0600 local_action: copy content={{ ansible_hostname }} dest=/tmp/kolla_mariadb_cluster mode=0600
changed_when: False changed_when: False
always_run: True always_run: True
when: exists.rc == 0 when: not mariadb_volume | changed
- name: Registering host from temp file - name: Registering host from temp file
set_fact: set_fact:
...@@ -44,7 +42,6 @@ ...@@ -44,7 +42,6 @@
KOLLA_BOOTSTRAP: KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
DB_ROOT_PASSWORD: "{{ database_password }}" DB_ROOT_PASSWORD: "{{ database_password }}"
DB_PID_FILE: "/var/lib/mysql/{{ hostvars[inventory_hostname]['ansible_hostname'] }}-galera.pid"
DB_MAX_TIMEOUT: "{{ database_max_timeout }}" DB_MAX_TIMEOUT: "{{ database_max_timeout }}"
image: "{{ mariadb_image_full }}" image: "{{ mariadb_image_full }}"
name: "mariadb" name: "mariadb"
...@@ -52,13 +49,17 @@ ...@@ -52,13 +49,17 @@
volumes: volumes:
- "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro" - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- "mariadb:/var/lib/mysql" - "mariadb:/var/lib/mysql"
when: delegate_host == 'None' and inventory_hostname == groups['mariadb'][0] when:
- delegate_host == 'None'
- inventory_hostname == groups['mariadb'][0]
- name: Waiting for MariaDB service to be ready - name: Waiting for MariaDB service to be ready
command: "docker exec mariadb ls /var/lib/mysql/{{ hostvars[inventory_hostname]['ansible_hostname'] }}-galera.pid /var/lib/mysql/cluster.exists" command: "docker exec mariadb ls /var/lib/mysql/mariadb.pid"
register: bootstrap_result register: bootstrap_result
when: delegate_host == 'None' and inventory_hostname == groups['mariadb'][0] when:
until: bootstrap_result|success - delegate_host == 'None'
- inventory_hostname == groups['mariadb'][0]
until: bootstrap_result | success
changed_when: False changed_when: False
retries: 6 retries: 6
delay: 10 delay: 10
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
( delegate_host == 'None' and inventory_hostname != groups['mariadb'][0] ) ( delegate_host == 'None' and inventory_hostname != groups['mariadb'][0] )
- name: Waiting for MariaDB service to be ready - name: Waiting for MariaDB service to be ready
command: "docker exec mariadb ls /var/lib/mysql/{{ hostvars[inventory_hostname]['ansible_hostname'] }}-galera.pid" command: "docker exec mariadb ls /var/lib/mysql/mariadb.pid"
register: bootstrap_result register: bootstrap_result
when: delegate_host != 'None' or when: delegate_host != 'None' or
( groups['mariadb'] | length ) == 1 or ( groups['mariadb'] | length ) == 1 or
......
...@@ -26,4 +26,4 @@ wsrep_slave_threads=4 ...@@ -26,4 +26,4 @@ wsrep_slave_threads=4
max_connections=1000 max_connections=1000
[server] [server]
pid-file=/var/lib/mysql/{{ ansible_hostname }}-galera.pid pid-file=/var/lib/mysql/mariadb.pid
...@@ -4,7 +4,7 @@ function bootstrap_db { ...@@ -4,7 +4,7 @@ function bootstrap_db {
mysqld_safe --wsrep-new-cluster & mysqld_safe --wsrep-new-cluster &
# Wait for the mariadb server to be "Ready" before starting the security reset with a max timeout # Wait for the mariadb server to be "Ready" before starting the security reset with a max timeout
TIMEOUT=${DB_MAX_TIMEOUT:-60} TIMEOUT=${DB_MAX_TIMEOUT:-60}
while [ ! -f ${DB_PID_FILE} ]; do while [[ ! -f /var/lib/mysql/mariadb.pid ]]; do
if [[ ${TIMEOUT} -gt 0 ]]; then if [[ ${TIMEOUT} -gt 0 ]]; then
let TIMEOUT-=1 let TIMEOUT-=1
sleep 1 sleep 1
...@@ -18,7 +18,10 @@ function bootstrap_db { ...@@ -18,7 +18,10 @@ function bootstrap_db {
mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" shutdown mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" shutdown
} }
sudo chown mysql: /var/lib/mysql # Only update permissions if permissions need to be updated
if [[ $(stat -c %U:%G /var/lib/mysql) != "mysql:mysql" ]]; then
sudo chown mysql: /var/lib/mysql
fi
# This catches all cases of the BOOTSTRAP variable being set, including empty # This catches all cases of the BOOTSTRAP variable being set, including empty
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]] && [[ ! -e /var/lib/mysql/cluster.exists ]]; then if [[ "${!KOLLA_BOOTSTRAP[@]}" ]] && [[ ! -e /var/lib/mysql/cluster.exists ]]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment