From 99b87fba18cab3b93e18481dc0f25b58c2472653 Mon Sep 17 00:00:00 2001 From: Damien Ciabrini Date: Thu, 31 Jan 2019 21:57:12 +0000 Subject: [PATCH] mysql: do not stop container when upgrade doesn't update mysql image In 0015cc74416445c3cf4e18e566a954f609f7cf0f we added the ability to stop gracefully the mysql container during a major upgrade, to allow upgrade to versions of mysql with different redo log format [1]. Stopping mysql is OK as long as paunch restarts it during the deploy tasks. However, paunch only (re)start mysql if the mysql config hash changes, it doesn't check whether mysql is stopped or not. So running "undercloud upgrade" with identical mysql container image now fails. Fix the upgrade strategy by stopping mysql only when needed, that is when mysql container image is to be updated. [1] https://jira.mariadb.org/browse/MDEV-14848 Change-Id: I88f1913581e6c9e279bcaf99ad4260dd940636c3 --- docker/services/database/mysql.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docker/services/database/mysql.yaml b/docker/services/database/mysql.yaml index 698d16ac66..49df180a6e 100644 --- a/docker/services/database/mysql.yaml +++ b/docker/services/database/mysql.yaml @@ -246,8 +246,9 @@ outputs: # LP 1810136 # After upgrade, the new mariadb (e.g. 10.3) might not be able # to replay the redo log of an older one (e.g. 10.1) if mysql - # stopped unexpectedly. Force it to stop and clean the redo log - # here to avoid issue after upgrade. + # stopped unexpectedly. If the container image differs, force + # mysql to stop and clean the redo log here to avoid issue after + # upgrade. - name: Stop MySQL server and ensure redo log is cleaned up before upgrade when: step|int == 2 block: @@ -272,6 +273,9 @@ outputs: - name: Mysql container facts set_fact: mysql_json: "{{ mysql_paunch_docker.stdout if mysql_paunch_docker.changed else mysql_paunch.stdout | from_json }}" + - name: Mysql container image after upgrade + set_fact: + post_upgrade_mysql_image: {get_param: DockerMysqlImage} - name: Redo log clean-up script set_fact: # The purpose of this script is to start mysql so that it @@ -290,6 +294,7 @@ outputs: shell: | {{ mysql_json.cli }} update --restart=unless-stopped mysql {{ mysql_json.cli }} stop mysql + when: mysql_json.image != post_upgrade_mysql_image - name: Clean up redo log by running a transient mysql server shell: str_replace: @@ -300,6 +305,7 @@ outputs: IMAGE: "{{ mysql_json.image }}" VOLUMES: "-v {{ mysql_clean_up_volumes | join(' -v ') }}" SCRIPT: "{{ mysql_clean_up_script }}" + when: mysql_json.image != post_upgrade_mysql_image post_upgrade_tasks: - when: step|int == 1 import_role: