From e51edb0dce9d69f1798f226ba1ce927c283688ea Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 3 Mar 2016 14:37:29 +0100 Subject: [PATCH] Readd iscsi_target table Rolling upgrades was broken when iscsi_target table was dropped on https://review.openstack.org/268320 We cannot stop using a table and drop it in the same release for rolling upgrades to work, we have to stop using it in one release and then drop it in the next or in the post rolling upgrade mechanism (which is still not in place). So this patch fixes this by removing the dropping and adding another migration that ensure that the table is really there. That way we can be sure that anyone using M will have the table, which then will get dropped in N. Closes-Bug: #1553079 Change-Id: I26586549485a8d745a25161d97d33426fdd52576 --- ...si_targets_table.py => 063_placeholder.py} | 9 ++--- .../versions/067_readd_iscsi_targets_table.py | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) rename cinder/db/sqlalchemy/migrate_repo/versions/{063_drop_iscsi_targets_table.py => 063_placeholder.py} (78%) create mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/067_readd_iscsi_targets_table.py diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/063_drop_iscsi_targets_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/063_placeholder.py similarity index 78% rename from cinder/db/sqlalchemy/migrate_repo/versions/063_drop_iscsi_targets_table.py rename to cinder/db/sqlalchemy/migrate_repo/versions/063_placeholder.py index f88279471..b74fdeef0 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/063_drop_iscsi_targets_table.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/063_placeholder.py @@ -10,11 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -from sqlalchemy import MetaData, Table - def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - table = Table('iscsi_targets', meta, autoload=True) - table.drop() + # This used to drop iscsi_targets, but since dropping it before L release + # stops using it breaks rolling upgrades we postpone the dropping until N. + pass diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/067_readd_iscsi_targets_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/067_readd_iscsi_targets_table.py new file mode 100644 index 000000000..4efe0ed48 --- /dev/null +++ b/cinder/db/sqlalchemy/migrate_repo/versions/067_readd_iscsi_targets_table.py @@ -0,0 +1,39 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import Boolean, Column, DateTime, ForeignKey +from sqlalchemy import Integer, MetaData, String, Table + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + table = Table( + 'iscsi_targets', meta, + Column('created_at', DateTime), + Column('updated_at', DateTime), + Column('deleted_at', DateTime), + Column('deleted', Boolean), + Column('id', Integer, primary_key=True, nullable=False), + Column('target_num', Integer), + Column('host', String(length=255)), + Column('volume_id', String(length=36), ForeignKey('volumes.id'), + nullable=True), + mysql_engine='InnoDB', + mysql_charset='utf8' + ) + + # We use checkfirst argument because this table may already exist if the + # migration is performed on a system that was on a migration earlier than + # 063 when performing the upgrade. + table.create(checkfirst=True)