Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kolla Ansible
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Very Demiurge Very Mindful
Kolla Ansible
Commits
4fc523c3
Commit
4fc523c3
authored
5 years ago
by
Zuul
Committed by
Gerrit Code Review
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Fixes for MariaDB bootstrap and recovery"
parents
ec786459
86f373a1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ansible/roles/mariadb/handlers/main.yml
+24
-0
24 additions, 0 deletions
ansible/roles/mariadb/handlers/main.yml
ansible/roles/mariadb/tasks/recover_cluster.yml
+27
-8
27 additions, 8 deletions
ansible/roles/mariadb/tasks/recover_cluster.yml
with
51 additions
and
8 deletions
ansible/roles/mariadb/handlers/main.yml
+
24
−
0
View file @
4fc523c3
...
@@ -42,6 +42,24 @@
...
@@ -42,6 +42,24 @@
-
bootstrap_host == inventory_hostname
-
bootstrap_host == inventory_hostname
listen
:
Bootstrap MariaDB cluster
listen
:
Bootstrap MariaDB cluster
-
name
:
Wait for MariaDB to become operational
become
:
true
command
:
>-
docker exec {{ mariadb_service.container_name }}
mysql -uroot -p{{ database_password }}
--silent --skip-column-names
-e 'SHOW STATUS LIKE "wsrep_evs_state"'
changed_when
:
false
register
:
result
until
:
'
"OPERATIONAL"
in
result.stdout'
retries
:
10
delay
:
6
no_log
:
true
when
:
-
bootstrap_host is defined
-
bootstrap_host == inventory_hostname
listen
:
Bootstrap MariaDB cluster
-
name
:
restart slave mariadb
-
name
:
restart slave mariadb
vars
:
vars
:
service_name
:
"
mariadb"
service_name
:
"
mariadb"
...
@@ -57,6 +75,7 @@
...
@@ -57,6 +75,7 @@
when
:
when
:
-
kolla_action != "config"
-
kolla_action != "config"
-
inventory_hostname != master_host
-
inventory_hostname != master_host
-
not mariadb_recover | default(false)
listen
:
restart mariadb
listen
:
restart mariadb
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
...
@@ -75,6 +94,7 @@
...
@@ -75,6 +94,7 @@
when
:
when
:
-
kolla_action != "config"
-
kolla_action != "config"
-
inventory_hostname != master_host
-
inventory_hostname != master_host
-
not mariadb_recover | default(false)
listen
:
restart mariadb
listen
:
restart mariadb
-
name
:
run upgrade on slave
-
name
:
run upgrade on slave
...
@@ -103,6 +123,7 @@
...
@@ -103,6 +123,7 @@
when
:
when
:
-
kolla_action == "upgrade"
-
kolla_action == "upgrade"
-
inventory_hostname != master_host
-
inventory_hostname != master_host
-
not mariadb_recover | default(false)
listen
:
restart mariadb
listen
:
restart mariadb
-
name
:
restart master mariadb
-
name
:
restart master mariadb
...
@@ -120,6 +141,7 @@
...
@@ -120,6 +141,7 @@
when
:
when
:
-
kolla_action != "config"
-
kolla_action != "config"
-
inventory_hostname == master_host
-
inventory_hostname == master_host
-
not mariadb_recover | default(false)
listen
:
restart mariadb
listen
:
restart mariadb
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
...
@@ -138,6 +160,7 @@
...
@@ -138,6 +160,7 @@
when
:
when
:
-
kolla_action != "config"
-
kolla_action != "config"
-
inventory_hostname == master_host
-
inventory_hostname == master_host
-
not mariadb_recover | default(false)
listen
:
restart mariadb
listen
:
restart mariadb
-
name
:
run upgrade on master
-
name
:
run upgrade on master
...
@@ -166,4 +189,5 @@
...
@@ -166,4 +189,5 @@
when
:
when
:
-
kolla_action == "upgrade"
-
kolla_action == "upgrade"
-
inventory_hostname == master_host
-
inventory_hostname == master_host
-
not mariadb_recover | default(false)
listen
:
restart mariadb
listen
:
restart mariadb
This diff is collapsed.
Click to expand it.
ansible/roles/mariadb/tasks/recover_cluster.yml
+
27
−
8
View file @
4fc523c3
...
@@ -26,36 +26,37 @@
...
@@ -26,36 +26,37 @@
name
:
"
{{
mariadb_service.container_name
}}"
name
:
"
{{
mariadb_service.container_name
}}"
action
:
"
stop_container"
action
:
"
stop_container"
# Run wsrep recovery with detach=false to block until completion. Use a
# different container name to avoid the mariadb container being removed.
-
name
:
Run MariaDB wsrep recovery
-
name
:
Run MariaDB wsrep recovery
become
:
true
become
:
true
kolla_docker
:
kolla_docker
:
action
:
"
start_container"
action
:
"
start_container"
common_options
:
"
{{
docker_common_options
}}"
common_options
:
"
{{
docker_common_options
}}"
detach
:
false
environment
:
environment
:
KOLLA_CONFIG_STRATEGY
:
"
{{
config_strategy
}}"
KOLLA_CONFIG_STRATEGY
:
"
{{
config_strategy
}}"
BOOTSTRAP_ARGS
:
"
--wsrep-recover"
BOOTSTRAP_ARGS
:
"
--wsrep-recover"
image
:
"
{{
mariadb_service.image
}}"
image
:
"
{{
mariadb_service.image
}}"
labels
:
labels
:
BOOTSTRAP
:
BOOTSTRAP
:
name
:
"
{{
mariadb_
service.container_name
}}"
name
:
mariadb_
wsrep_recovery
restart_policy
:
"
never"
restart_policy
:
"
never"
volumes
:
"
{{
mariadb_service.volumes
}}"
volumes
:
"
{{
mariadb_service.volumes
}}"
-
name
:
Stop MariaDB containers
become
:
true
kolla_docker
:
name
:
"
{{
mariadb_service.container_name
}}"
action
:
"
stop_container"
-
name
:
Copying MariaDB log file to /tmp
-
name
:
Copying MariaDB log file to /tmp
become
:
true
become
:
true
shell
:
"
docker
cp
{{
mariadb_service.container_name
}}:/var/log/kolla/mariadb/mariadb.log
/tmp/mariadb_tmp.log"
shell
:
"
docker
cp
{{
mariadb_service.container_name
}}:/var/log/kolla/mariadb/mariadb.log
/tmp/mariadb_tmp.log"
# Look for sequence number in logs. Format is:
# WSREP: Recovered position: <UUID>:<seqno>.
-
name
:
Get MariaDB wsrep recovery seqno
-
name
:
Get MariaDB wsrep recovery seqno
shell
:
tail -n 200 /tmp/mariadb_tmp.log | awk -F" " '$0~/Recovered position/{print $NF;exit;}' | awk -F":" '{print $1}'
become
:
true
shell
:
tail -n 200 /tmp/mariadb_tmp.log | awk -F" " '$0~/Recovered position/{print $NF;exit;}' | awk -F":" '{print $2}'
register
:
wsrep_recovery_seqno
register
:
wsrep_recovery_seqno
-
name
:
Removing MariaDB log file from /tmp
-
name
:
Removing MariaDB log file from /tmp
become
:
true
file
:
file
:
path
:
/tmp/mariadb_tmp.log
path
:
/tmp/mariadb_tmp.log
state
:
absent
state
:
absent
...
@@ -104,6 +105,7 @@
...
@@ -104,6 +105,7 @@
-
bootstrap_host == inventory_hostname
-
bootstrap_host == inventory_hostname
-
name
:
Set grastate.dat file from MariaDB container in bootstrap host
-
name
:
Set grastate.dat file from MariaDB container in bootstrap host
become
:
true
lineinfile
:
lineinfile
:
dest
:
/tmp/kolla_mariadb_grastate.dat
dest
:
/tmp/kolla_mariadb_grastate.dat
regexp
:
'
safe_to_bootstrap:(.*)$'
regexp
:
'
safe_to_bootstrap:(.*)$'
...
@@ -162,6 +164,23 @@
...
@@ -162,6 +164,23 @@
-
bootstrap_host is defined
-
bootstrap_host is defined
-
bootstrap_host == inventory_hostname
-
bootstrap_host == inventory_hostname
-
name
:
Wait for MariaDB to become operational
become
:
true
command
:
>-
docker exec {{ mariadb_service.container_name }}
mysql -uroot -p{{ database_password }}
--silent --skip-column-names
-e 'SHOW STATUS LIKE "wsrep_evs_state"'
changed_when
:
false
register
:
result
until
:
'
"OPERATIONAL"
in
result.stdout'
retries
:
10
delay
:
6
no_log
:
true
when
:
-
bootstrap_host is defined
-
bootstrap_host == inventory_hostname
-
name
:
Restart slave MariaDB container
-
name
:
Restart slave MariaDB container
become
:
true
become
:
true
kolla_docker
:
kolla_docker
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment