From 08b90190085a11bc99112472944c193672061e1f Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 25 Jul 2014 13:30:21 -0700 Subject: [PATCH] Modify the index migration slightly for backport 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 --- .../023_add_expire_reservations_index.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/023_add_expire_reservations_index.py b/cinder/db/sqlalchemy/migrate_repo/versions/023_add_expire_reservations_index.py index 52f0461d4..eb9edabcd 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/023_add_expire_reservations_index.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/023_add_expire_reservations_index.py @@ -13,7 +13,12 @@ # 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.')) -- 2.45.2