aboutsummaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorJiri Stransky <jistr@redhat.com>2017-03-03 15:00:37 +0100
committerJiri Stransky <jistr@redhat.com>2017-03-14 13:52:55 +0000
commitcd88f4d8e928daf0676a4a9b6f36d93df7a6aa7c (patch)
tree6897e73789a3036e6e522a7b1adbe9b1af30e768 /docker
parenta681b985643f62de447039f25944e7c2d2347d28 (diff)
Keep existing data when moving to containerized MariaDB
We used named Docker volume for MariaDB storage, which meant that when moving from BM to containerized wit MariaDB, we lost data and reinitialized the storage from scratch. With this commit we keep the data by mounting the original data into the container. We also need to make sure that file ownership is correct according to the MariaDB container image used, and that Kolla bootstrap mechanisms aren't retriggered, as they aren't idempotent. Change-Id: I1fc955021c6dd83f1a366495dd8c7281fb9e7cc5
Diffstat (limited to 'docker')
-rw-r--r--docker/services/database/mysql.yaml25
1 files changed, 21 insertions, 4 deletions
diff --git a/docker/services/database/mysql.yaml b/docker/services/database/mysql.yaml
index 46b856e3..531c1ebd 100644
--- a/docker/services/database/mysql.yaml
+++ b/docker/services/database/mysql.yaml
@@ -82,17 +82,29 @@ outputs:
perm: '0644'
docker_config:
step_2:
- mysql_bootstrap:
+ mysql_data_ownership:
start_order: 0
detach: false
image: *mysql_image
net: host
+ user: root
+ # Kolla does only non-recursive chown
+ command: ['chown', '-R', 'mysql:', '/var/lib/mysql']
+ volumes:
+ - /var/lib/mysql:/var/lib/mysql
+ mysql_bootstrap:
+ start_order: 1
+ detach: false
+ image: *mysql_image
+ net: host
+ # Kolla bootstraps aren't idempotent, explicitly checking if bootstrap was done
+ command: ['bash', '-c', 'test -e /var/lib/mysql/mysql || kolla_start']
volumes: &mysql_volumes
- /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
- /var/lib/config-data/mysql/:/var/lib/kolla/config_files/src:ro
- /etc/localtime:/etc/localtime:ro
- /etc/hosts:/etc/hosts:ro
- - mariadb:/var/lib/mysql/
+ - /var/lib/mysql:/var/lib/mysql
environment:
- KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
- KOLLA_BOOTSTRAP=True
@@ -110,7 +122,7 @@ outputs:
- {get_param: MysqlRootPassword}
- {get_param: [DefaultPasswords, mysql_root_password]}
mysql:
- start_order: 1
+ start_order: 2
image: *mysql_image
restart: always
net: host
@@ -128,8 +140,13 @@ outputs:
- '/'
- [ {get_param: DockerNamespace}, {get_param: DockerMysqlImage} ]
volumes:
- - "mariadb:/var/lib/mysql/:ro"
+ - "/var/lib/mysql:/var/lib/mysql/:ro"
- "/var/lib/config-data/mysql/root:/root:ro" #provides .my.cnf
+ host_prep_tasks:
+ - name: create /var/lib/mysql
+ file:
+ path: /var/lib/mysql
+ state: directory
upgrade_tasks:
- name: Stop and disable mysql service
tags: step2