Upgrade data on disk on mariadb major upgrade
Add an ansible task to run mysql_upgrade whenever a container image upgrade causes a major upgrade of mariadb (e.g. 5.5 -> 10.1) . If the overcloud was containerized prior to the major upgrade, the mysql upgrade job is ran in an ephemeral container (where the latest version of mysql comes from) and uses credentials from the Kolla configuration. . Otherwise the upgrade job is run from the host (once the mysql rpm has been updated) and uses credentials from the host. We log the output of the script in the journal. Also, the mysql server needs to be started temporarily, so use a temporary log file for it when run from the ephemeral container. Change-Id: Id330d634ee214923407ea893fdf7a189dc477e5c
This commit is contained in:
parent
84c895fd4a
commit
624fedb114
|
@ -401,3 +401,36 @@ outputs:
|
|||
- step|int == 3
|
||||
- mysql_containerized|bool
|
||||
block: *mysql_fetch_retag_container_tasks
|
||||
- name: Check and upgrade Mysql database after major version upgrade
|
||||
when: step|int == 4
|
||||
block:
|
||||
- name: Mysql upgrade script
|
||||
set_fact:
|
||||
mysql_upgrade_script:
|
||||
# idempotency: mysql_upgrade leaves a marker file
|
||||
# in datadir, it does nothing if it has already been
|
||||
# executed for the current version of MariaDB.
|
||||
list_join:
|
||||
- ' '
|
||||
- - '{% if mysql_containerized %}sudo -E kolla_set_configs; {% endif %}'
|
||||
- 'mysqld_safe --user=mysql --wsrep-provider=none --skip-networking --wsrep-on=off &'
|
||||
- 'timeout 60 sh -c ''while ! mysqladmin ping --silent; do sleep 1; done'';'
|
||||
- 'mysql_upgrade;'
|
||||
- 'mysqladmin shutdown'
|
||||
- name: Bind mounts for temporary container
|
||||
set_fact:
|
||||
mysql_upgrade_db_bind_mounts: *mysql_volumes
|
||||
- name: Upgrade Mysql database from a temporary container
|
||||
shell:
|
||||
str_replace:
|
||||
template:
|
||||
'/usr/bin/docker run --rm --log-driver=syslog -u root --net=host UPGRADE_ENV UPGRADE_VOLUMES "UPGRADE_IMAGE" /bin/bash -ecx "UPGRADE_SCRIPT"'
|
||||
params:
|
||||
UPGRADE_ENV: '-e "KOLLA_CONFIG_STRATEGY=COPY_ALWAYS"'
|
||||
UPGRADE_IMAGE: *mysql_image_pcmklatest
|
||||
UPGRADE_VOLUMES: "-v {{ mysql_upgrade_db_bind_mounts | union(['/tmp/mariadb-upgrade:/var/log/mariadb:rw']) | join(' -v ')}}"
|
||||
UPGRADE_SCRIPT: "{{mysql_upgrade_script}}"
|
||||
when: mysql_containerized|bool
|
||||
- name: Upgrade Mysql database from the host
|
||||
shell: /bin/bash -ecx "{{mysql_upgrade_script}}"
|
||||
when: not mysql_containerized|bool
|
||||
|
|
Loading…
Reference in New Issue