aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-03-17 06:24:32 +0000
committerGerrit Code Review <review@openstack.org>2016-03-17 06:24:32 +0000
commit3c0641b36b3b606d2200035de0cab47a6d461fb2 (patch)
tree4e1f3e9153ada385e0b516d346b508e0657feeeb
parent9faefc25c94ce2216f2880c0bd0db25338157832 (diff)
parent2aaaed770e158c3dc0d6e1895021c0e0475d200d (diff)
downloadkolla-3c0641b36b3b606d2200035de0cab47a6d461fb2.tar.gz
kolla-3c0641b36b3b606d2200035de0cab47a6d461fb2.zip
Merge "MariaDB lights out recovery"2.0.0.0rc1
-rw-r--r--ansible/mariadb_recovery.yml8
-rw-r--r--ansible/roles/mariadb/tasks/bootstrap.yml69
-rw-r--r--ansible/roles/mariadb/tasks/bootstrap_cluster.yml31
-rw-r--r--ansible/roles/mariadb/tasks/lookup_cluster.yml35
-rw-r--r--ansible/roles/mariadb/tasks/recover_cluster.yml39
-rw-r--r--docker/mariadb/extend_start.sh1
-rwxr-xr-xtools/kolla-ansible6
7 files changed, 123 insertions, 66 deletions
diff --git a/ansible/mariadb_recovery.yml b/ansible/mariadb_recovery.yml
new file mode 100644
index 000000000..53cf73b42
--- /dev/null
+++ b/ansible/mariadb_recovery.yml
@@ -0,0 +1,8 @@
+---
+- hosts: mariadb
+ roles:
+ - { role: mariadb,
+ tags: mariadb,
+ when: enable_mariadb | bool }
+ vars:
+ mariadb_recover: true
diff --git a/ansible/roles/mariadb/tasks/bootstrap.yml b/ansible/roles/mariadb/tasks/bootstrap.yml
index f6a184261..6647cb598 100644
--- a/ansible/roles/mariadb/tasks/bootstrap.yml
+++ b/ansible/roles/mariadb/tasks/bootstrap.yml
@@ -1,71 +1,10 @@
---
-- name: Cleaning up temp file on localhost
- local_action: file path=/tmp/kolla_mariadb_cluster state=absent
- changed_when: False
- always_run: True
- run_once: True
+- include: lookup_cluster.yml
-- name: Creating temp file on localhost
- local_action: copy content=None dest=/tmp/kolla_mariadb_cluster mode=0600
- changed_when: False
- always_run: True
- run_once: True
-
-- name: Creating mariadb volume
- kolla_docker:
- action: "create_volume"
- common_options: "{{ docker_common_options }}"
- name: "mariadb"
- register: mariadb_volume
-
-- 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
- changed_when: False
- always_run: True
- when: not mariadb_volume | changed
-
-- name: Registering host from temp file
- set_fact:
- delegate_host: "{{ lookup('file', '/tmp/kolla_mariadb_cluster') }}"
-
-- name: Cleaning up temp file on localhost
- local_action: file path=/tmp/kolla_mariadb_cluster state=absent
- changed_when: False
- always_run: True
- run_once: True
-
-- name: Starting MariaDB bootstrap container
- kolla_docker:
- action: "start_container"
- common_options: "{{ docker_common_options }}"
- environment:
- KOLLA_BOOTSTRAP:
- KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
- DB_ROOT_PASSWORD: "{{ database_password }}"
- DB_MAX_TIMEOUT: "{{ database_max_timeout }}"
- image: "{{ mariadb_image_full }}"
- labels:
- BOOTSTRAP:
- name: "mariadb"
- restart_policy: "never"
- volumes:
- - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- - "mariadb:/var/lib/mysql"
- - "kolla_logs:/var/log/kolla/"
+- include: bootstrap_cluster.yml
when:
- delegate_host == 'None'
- inventory_hostname == groups['mariadb'][0]
-- name: Waiting for MariaDB service to be ready
- command: "docker exec mariadb ls /var/lib/mysql/{{ item }}"
- register: bootstrap_result
- when:
- - delegate_host == 'None'
- - inventory_hostname == groups['mariadb'][0]
- until: bootstrap_result | success
- changed_when: False
- retries: 6
- delay: 10
- with_items:
- - cluster.exists
- - mariadb.pid
+- include: recover_cluster.yml
+ when: mariadb_recover | default(False)
diff --git a/ansible/roles/mariadb/tasks/bootstrap_cluster.yml b/ansible/roles/mariadb/tasks/bootstrap_cluster.yml
new file mode 100644
index 000000000..6c3c8537f
--- /dev/null
+++ b/ansible/roles/mariadb/tasks/bootstrap_cluster.yml
@@ -0,0 +1,31 @@
+---
+- name: Starting MariaDB bootstrap container
+ kolla_docker:
+ action: "start_container"
+ common_options: "{{ docker_common_options }}"
+ environment:
+ KOLLA_BOOTSTRAP:
+ KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
+ DB_ROOT_PASSWORD: "{{ database_password }}"
+ DB_MAX_TIMEOUT: "{{ database_max_timeout }}"
+ ARGS: "--wsrep-new-cluster"
+ image: "{{ mariadb_image_full }}"
+ labels:
+ BOOTSTRAP:
+ name: "mariadb"
+ restart_policy: "never"
+ volumes:
+ - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
+ - "kolla_logs:/var/log/kolla/"
+ - "mariadb:/var/lib/mysql"
+
+- name: Waiting for MariaDB service to be ready
+ command: "docker exec mariadb ls /var/lib/mysql/{{ item }}"
+ register: bootstrap_result
+ until: bootstrap_result | success
+ changed_when: False
+ retries: 6
+ delay: 10
+ with_items:
+ - cluster.exists
+ - mariadb.pid
diff --git a/ansible/roles/mariadb/tasks/lookup_cluster.yml b/ansible/roles/mariadb/tasks/lookup_cluster.yml
new file mode 100644
index 000000000..b14afedc8
--- /dev/null
+++ b/ansible/roles/mariadb/tasks/lookup_cluster.yml
@@ -0,0 +1,35 @@
+---
+- name: Cleaning up temp file on localhost
+ local_action: file path=/tmp/kolla_mariadb_cluster state=absent
+ changed_when: False
+ always_run: True
+ run_once: True
+
+- name: Creating temp file on localhost
+ local_action: copy content=None dest=/tmp/kolla_mariadb_cluster mode=0600
+ changed_when: False
+ always_run: True
+ run_once: True
+
+- name: Creating mariadb volume
+ kolla_docker:
+ action: "create_volume"
+ common_options: "{{ docker_common_options }}"
+ name: "mariadb"
+ register: mariadb_volume
+
+- 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
+ changed_when: False
+ always_run: True
+ when: not mariadb_volume | changed
+
+- name: Registering host from temp file
+ set_fact:
+ delegate_host: "{{ lookup('file', '/tmp/kolla_mariadb_cluster') }}"
+
+- name: Cleaning up temp file on localhost
+ local_action: file path=/tmp/kolla_mariadb_cluster state=absent
+ changed_when: False
+ always_run: True
+ run_once: True
diff --git a/ansible/roles/mariadb/tasks/recover_cluster.yml b/ansible/roles/mariadb/tasks/recover_cluster.yml
new file mode 100644
index 000000000..2a19c11ac
--- /dev/null
+++ b/ansible/roles/mariadb/tasks/recover_cluster.yml
@@ -0,0 +1,39 @@
+---
+- fail:
+ msg: "MariaDB cluster was not found. Is your inventory correct?"
+ when: delegate_host == 'None'
+
+- name: Checking if and mariadb containers are running
+ kolla_docker:
+ name: "mariadb"
+ action: "get_container_state"
+ register: container_state
+
+- fail:
+ msg: "There are running MariaDB nodes, please stop them first."
+ when: container_state.Running | bool
+ any_errors_fatal: True
+
+- name: Starting first MariaDB container
+ kolla_docker:
+ action: "start_container"
+ common_options: "{{ docker_common_options }}"
+ environment:
+ KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
+ ARGS: "--wsrep-new-cluster"
+ image: "{{ mariadb_image_full }}"
+ labels:
+ BOOTSTRAP:
+ name: "mariadb"
+ restart_policy: "never"
+ volumes:
+ - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
+ - "kolla_logs:/var/log/kolla/"
+ - "mariadb:/var/lib/mysql"
+ when:
+ - (mariadb_recover_inventory_name is not defined and inventory_hostname == groups['mariadb'][0]) or
+ (mariadb_recover_inventory_name is defined and inventory_hostname == mariadb_recover_inventory_name)
+
+- name: Reset bootstrap fact
+ set_fact:
+ delegate_host: "None"
diff --git a/docker/mariadb/extend_start.sh b/docker/mariadb/extend_start.sh
index f6de85c36..3d826c4e8 100644
--- a/docker/mariadb/extend_start.sh
+++ b/docker/mariadb/extend_start.sh
@@ -33,7 +33,6 @@ fi
# This catches all cases of the BOOTSTRAP variable being set, including empty
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]] && [[ ! -e /var/lib/mysql/cluster.exists ]]; then
- ARGS="--wsrep-new-cluster"
mysql_install_db
bootstrap_db
touch /var/lib/mysql/cluster.exists
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index 0a1965cdb..11ed742c7 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -38,6 +38,7 @@ Options:
Commands:
prechecks Do pre-deployment checks for hosts
+ mariadb_recovery Recover a completely stopped mariadb cluster
deploy Deploy and start all kolla containers
post-deploy Do post deploy on deploy node
pull Pull all images for containers (only pulls, no runnnig container changes)
@@ -119,6 +120,11 @@ case "$1" in
ACTION="Pre-deployment checking"
PLAYBOOK="${BASEDIR}/ansible/prechecks.yml"
;;
+(mariadb_recovery)
+ ACTION="Attempting to restart mariadb cluster"
+ EXTRA_OPTS="$EXTRA_OPTS -e action=deploy"
+ PLAYBOOK="${BASEDIR}/ansible/mariadb_recovery.yml"
+ ;;
(deploy)
ACTION="Deploying Playbooks"
EXTRA_OPTS="$EXTRA_OPTS -e action=deploy"