From 0ccc67afcacad386940c88a2e58795c0b068ea7c Mon Sep 17 00:00:00 2001 From: David Ames Date: Mon, 20 Mar 2017 13:20:26 -0700 Subject: [PATCH] Force DB Migrate on openstack-upgrade The is_db_initialised function was stopping migrate_database from performing the migration when running an openstack-upgrade. Add upgrade kwarg to guarantee the migration runs. Change-Id: I4f71f34f752f49992774e3d44e9105d35ca32d80 Closes-bug: #1674457 --- hooks/cinder_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/cinder_utils.py b/hooks/cinder_utils.py index fd516e00..0c70295e 100644 --- a/hooks/cinder_utils.py +++ b/hooks/cinder_utils.py @@ -687,7 +687,7 @@ def check_db_initialised(): # NOTE(jamespage): Retry deals with sync issues during one-shot HA deploys. # mysql might be restarting or suchlike. @retry_on_exception(5, base_delay=3, exc_type=subprocess.CalledProcessError) -def migrate_database(): +def migrate_database(upgrade=False): """Initialise cinder database if not already done so. Runs cinder-manage to initialize a new database or migrate existing and @@ -695,7 +695,7 @@ def migrate_database(): (leader) unit to perform this action should have broadcast this information to its peers so first we check whether this has already occurred. """ - if is_db_intialised(): + if not upgrade and is_db_intialised(): log("Database is already initialised.", level=DEBUG) return @@ -756,7 +756,7 @@ def do_openstack_upgrade(configs): # Stop/start services and migrate DB if leader [service_stop(s) for s in services()] if is_elected_leader(CLUSTER_RES): - migrate_database() + migrate_database(upgrade=True) if not is_unit_paused_set(): [service_start(s) for s in services()]