]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Modify the index migration slightly for backport
authorVishvananda Ishaya <vishvananda@gmail.com>
Fri, 25 Jul 2014 20:30:21 +0000 (13:30 -0700)
committerJay S. Bryant <jsbryant@us.ibm.com>
Sat, 26 Jul 2014 15:33:39 +0000 (10:33 -0500)
If we choose to backport this fix, the migration should be catching
an operational error. Also add a log statement as requested by the
nova review.

Change-Id: Ib33b8711900db9dc2826a099ff3cc6adffc8babb
Partial-bug: 1348720

cinder/db/sqlalchemy/migrate_repo/versions/023_add_expire_reservations_index.py

index 52f0461d4aec3eca2460a198309739aad46b5cdd..eb9edabcdfc0d7d018cde2d8882f66b59d50f6e8 100644 (file)
 #    under the License.
 
 from sqlalchemy import Index, MetaData, Table
-from sqlalchemy.exc import IntegrityError
+from sqlalchemy.exc import OperationalError
+
+from cinder.openstack.common.gettextutils import _
+from cinder.openstack.common import log as logging
+
+LOG = logging.getLogger(__name__)
 
 
 def upgrade(migrate_engine):
@@ -28,8 +33,9 @@ def upgrade(migrate_engine):
                   reservations.c.deleted, reservations.c.expire)
     try:
         index.create(migrate_engine)
-    except IntegrityError:
-        pass
+    except OperationalError:
+        LOG.info(_('Skipped adding reservations_deleted_expire_idx '
+                   'because an equivalent index already exists.'))
 
 
 def downgrade(migrate_engine):
@@ -40,4 +46,8 @@ def downgrade(migrate_engine):
 
     index = Index('reservations_deleted_expire_idx',
                   reservations.c.deleted, reservations.c.expire)
-    index.drop(migrate_engine)
+    try:
+        index.drop(migrate_engine)
+    except OperationalError:
+        LOG.info(_('Skipped removing reservations_deleted_expire_idx '
+                   'because index does not exist.'))