From 39930ed2fdafff0c11697b8326ff5f93b66c6b2a Mon Sep 17 00:00:00 2001
From: Jiri Stransky <jistr@redhat.com>
Date: Wed, 20 Mar 2019 15:08:52 +0100
Subject: [PATCH] Only attempt to start previous MariaDB if the image is
 available

On upgrade of undercloud from Rocky to Stein, we can't run this task
always. The old MariaDB image was in Docker, but after the upgrade
only Podman might be available, and it wouldn't have the previous
MariaDB image available. Our best option here is likely skipping the
redo log cleanup and hope that the redo log is clean. If this happens
to cause problems in the wild, we might need a completely different
solution (a parameter pointing to old MariaDB image url so that we can
re-download it etc.).

Change-Id: I51a338d840190c8931ab40692f727e5e0638ba40
Closes-Bug: #1821013
---
 deployment/database/mysql-container-puppet.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/deployment/database/mysql-container-puppet.yaml b/deployment/database/mysql-container-puppet.yaml
index 25b80a537e..bd748d379d 100644
--- a/deployment/database/mysql-container-puppet.yaml
+++ b/deployment/database/mysql-container-puppet.yaml
@@ -305,7 +305,7 @@ outputs:
               shell: |
                 {{ mysql_json.cli }} update --restart=unless-stopped mysql
                 {{ mysql_json.cli }} stop mysql
-              when: mysql_json.image != post_upgrade_mysql_image
+              when: mysql_json.image is defined and mysql_json.image != post_upgrade_mysql_image
             - name: Clean up redo log by running a transient mysql server
               shell:
                 str_replace:
@@ -316,7 +316,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
+              when: mysql_json.image is defined and mysql_json.image != post_upgrade_mysql_image
       post_upgrade_tasks:
         - when: step|int == 1
           import_role: