]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Readd iscsi_target table
authorGorka Eguileor <geguileo@redhat.com>
Thu, 3 Mar 2016 13:37:29 +0000 (14:37 +0100)
committerGorka Eguileor <geguileo@redhat.com>
Fri, 4 Mar 2016 09:07:05 +0000 (10:07 +0100)
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

cinder/db/sqlalchemy/migrate_repo/versions/063_placeholder.py [moved from cinder/db/sqlalchemy/migrate_repo/versions/063_drop_iscsi_targets_table.py with 78% similarity]
cinder/db/sqlalchemy/migrate_repo/versions/067_readd_iscsi_targets_table.py [new file with mode: 0644]

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 f8827947189bc80066d0d6bcff584cccefcbee23..b74fdeef0f22690828164b838752f2acac2362eb 100644 (file)
 #    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 (file)
index 0000000..4efe0ed
--- /dev/null
@@ -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)