]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove logging statements from migrations
authorJohn Griffith <john.griffith8@gmail.com>
Mon, 15 Jun 2015 21:23:39 +0000 (15:23 -0600)
committerJohn Griffith <john.griffith8@gmail.com>
Mon, 20 Jul 2015 20:46:15 +0000 (14:46 -0600)
One of the things that I believe is causing problems with the move to
ostestr and concurrency in unit test run is the copious amounts of
logging that is coming from the db migrations.  In most cases much of
this logging doesn't really seem all that useful, a debug or info log
stating a migration failed, followed by a raise which should generate
a stack trace with the error anyway, seems we could easily do without
this.

Also the "performing migration xxxx/completing migration xxxx" doesn't
seem overly helpful either.  Keep in mind that the migration engine
does some amount of logging anyway.

In addition, catching the exceptions and logging them isn't overly
beneficial or needed either.  When calling migrate from cinder-manage
if one of the migrations raises an exception that will be propogated
up to cinder-manage and displayed.  In other words all of the info is
already available, so there's no need to put it here.

Finally, if you take a look in general most migrations in other
projects don't LOG every thing for the same reasons.

So this patch removes logging statement from the migrations themeselves.

Change-Id: I285df7061c79c79e217cccb2fe387437c20ff746

25 files changed:
cinder/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py
cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py
cinder/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py
cinder/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py
cinder/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py
cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py
cinder/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py
cinder/db/sqlalchemy/migrate_repo/versions/010_add_transfers_table.py
cinder/db/sqlalchemy/migrate_repo/versions/015_drop_migrations_table.py
cinder/db/sqlalchemy/migrate_repo/versions/016_drop_sm_tables.py
cinder/db/sqlalchemy/migrate_repo/versions/017_add_encryption_information.py
cinder/db/sqlalchemy/migrate_repo/versions/018_add_qos_specs.py
cinder/db/sqlalchemy/migrate_repo/versions/020_add_volume_admin_metadata_table.py
cinder/db/sqlalchemy/migrate_repo/versions/021_add_default_quota_class.py
cinder/db/sqlalchemy/migrate_repo/versions/023_add_expire_reservations_index.py
cinder/db/sqlalchemy/migrate_repo/versions/024_add_replication_support.py
cinder/db/sqlalchemy/migrate_repo/versions/025_add_consistencygroup.py
cinder/db/sqlalchemy/migrate_repo/versions/026_add_consistencygroup_quota_class.py
cinder/db/sqlalchemy/migrate_repo/versions/032_add_volume_type_projects.py
cinder/db/sqlalchemy/migrate_repo/versions/037_add_cgsnapshot_id_column_to_consistencygroups.py
cinder/db/sqlalchemy/migrate_repo/versions/038_add_driver_initiator_data_table.py
cinder/db/sqlalchemy/migrate_repo/versions/039_add_parent_id_to_backups.py
cinder/db/sqlalchemy/migrate_repo/versions/040_add_volume_attachment.py
cinder/db/sqlalchemy/migrate_repo/versions/041_add_modified_at_column_to_service.py
cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py

index 4666a9a796ac7cff5795289e915a5744d22a51c1..a39aed63ce22ea58c1954a7a8cebe010b5ab5fe4 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime, ForeignKey
 from sqlalchemy import Integer, MetaData, String, Table
 
-from cinder.i18n import _LE, _LI
-
-
-LOG = logging.getLogger(__name__)
-
 
 def define_tables(meta):
     migrations = Table(
@@ -236,12 +230,7 @@ def upgrade(migrate_engine):
     tables = define_tables(meta)
 
     for table in tables:
-        try:
-            table.create()
-        except Exception:
-            LOG.info(repr(table))
-            LOG.exception(_LE('Exception while creating table.'))
-            raise
+        table.create()
 
     if migrate_engine.name == "mysql":
         tables = ["sm_flavors",
@@ -275,5 +264,4 @@ def downgrade(migrate_engine):
     tables = define_tables(meta)
     tables.reverse()
     for table in tables:
-        LOG.info(_LI("dropping table %(table)s"), {'table': table})
         table.drop()
index 6d801e0f449a02541c16bd6b10eb79c2cf7c0cf1..8d133ed80cba2bf702ad71cca97ae06a07d32340 100644 (file)
 #    under the License.
 
 from migrate import ForeignKeyConstraint
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -44,11 +39,7 @@ def upgrade(migrate_engine):
                           mysql_charset='utf8',
                           )
 
-    try:
-        quota_classes.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(quota_classes))
-        raise
+    quota_classes.create()
 
     quota_usages = Table('quota_usages', meta,
                          Column('created_at', DateTime(timezone=False)),
@@ -69,11 +60,7 @@ def upgrade(migrate_engine):
                          mysql_charset='utf8',
                          )
 
-    try:
-        quota_usages.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(quota_usages))
-        raise
+    quota_usages.create()
 
     reservations = Table('reservations', meta,
                          Column('created_at', DateTime(timezone=False)),
@@ -100,11 +87,7 @@ def upgrade(migrate_engine):
                          mysql_charset='utf8',
                          )
 
-    try:
-        reservations.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(reservations))
-        raise
+    reservations.create()
 
 
 def downgrade(migrate_engine):
@@ -128,29 +111,14 @@ def downgrade(migrate_engine):
               'name': fk_name}
 
     if fk_name:
-        try:
-            fkey = ForeignKeyConstraint(**params)
-            fkey.drop()
-        except Exception:
-            LOG.error(_LE("Dropping foreign key %s failed."), fk_name)
+        fkey = ForeignKeyConstraint(**params)
+        fkey.drop()
 
     quota_classes = Table('quota_classes', meta, autoload=True)
-    try:
-        quota_classes.drop()
-    except Exception:
-        LOG.error(_LE("quota_classes table not dropped"))
-        raise
+    quota_classes.drop()
 
     quota_usages = Table('quota_usages', meta, autoload=True)
-    try:
-        quota_usages.drop()
-    except Exception:
-        LOG.error(_LE("quota_usages table not dropped"))
-        raise
+    quota_usages.drop()
 
     reservations = Table('reservations', meta, autoload=True)
-    try:
-        reservations.drop()
-    except Exception:
-        LOG.error(_LE("reservations table not dropped"))
-        raise
+    reservations.drop()
index 52e1a61d65ea04fd7fb26ce11fda8c1a8c7df847..4c38c2dbe4653d617099785b98e43d9b51f77ede 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column, DateTime, Text, Boolean
 from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -56,8 +51,6 @@ def upgrade(migrate_engine):
     try:
         volume_glance_metadata.create()
     except Exception:
-        LOG.exception(_LE("Exception while creating table "
-                          "'volume_glance_metadata'"))
         meta.drop_all(tables=[volume_glance_metadata])
         raise
 
@@ -68,8 +61,4 @@ def downgrade(migrate_engine):
 
     volume_glance_metadata = Table('volume_glance_metadata',
                                    meta, autoload=True)
-    try:
-        volume_glance_metadata.drop()
-    except Exception:
-        LOG.error(_LE("volume_glance_metadata table not dropped"))
-        raise
+    volume_glance_metadata.drop()
index 745cdf43217ad79ea55c94251176c583c169b337..bbb6fa80cf4cd23bd521865bb886db7b36d369cc 100644 (file)
 import uuid
 
 from migrate import ForeignKeyConstraint
-from oslo_log import log as logging
 from sqlalchemy import Integer, MetaData, String, Table
 
-from cinder.i18n import _LI
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     """Convert volume_type_id to UUID."""
@@ -79,7 +74,6 @@ def upgrade(migrate_engine):
                                         name=fkey_name)
             try:
                 fkey.create()
-                LOG.info(_LI('Created foreign key %s'), fkey_name)
             except Exception:
                 if migrate_engine.url.get_dialect().name.startswith('sqlite'):
                     pass
@@ -158,7 +152,6 @@ def downgrade(migrate_engine):
                                         name=fkey_name)
             try:
                 fkey.create()
-                LOG.info(_LI('Created foreign key %s'), fkey_name)
             except Exception:
                 if migrate_engine.url.get_dialect().name.startswith('sqlite'):
                     pass
index caf8b54ed9ab101591a62fc33d20882595d825ad..2315ad38ca42eeea520fde884be989fb3c1cf3d1 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column
 from sqlalchemy import MetaData, String, Table
 
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     """Add source volume id column to volumes."""
index 9a899f37d268e2a5bda4d71fa6df94b96f01deed..9b50c89b7b8dde96b091823701ead2b5efaef541 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import MetaData, Integer, String, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -51,11 +46,7 @@ def upgrade(migrate_engine):
         mysql_engine='InnoDB'
     )
 
-    try:
-        backups.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(backups))
-        raise
+    backups.create()
 
 
 def downgrade(migrate_engine):
@@ -63,8 +54,4 @@ def downgrade(migrate_engine):
     meta.bind = migrate_engine
 
     backups = Table('backups', meta, autoload=True)
-    try:
-        backups.drop()
-    except Exception:
-        LOG.error(_LE("backups table not dropped"))
-        raise
+    backups.drop()
index 7c33382c8cc1a6d09599bbee42493615374fc7ec..86596db1a5c605965577703e5947041a07ff4ae4 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -40,11 +35,7 @@ def upgrade(migrate_engine):
         mysql_engine='InnoDB'
     )
 
-    try:
-        snapshot_metadata.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(snapshot_metadata))
-        raise
+    snapshot_metadata.create()
 
 
 def downgrade(migrate_engine):
@@ -53,8 +44,4 @@ def downgrade(migrate_engine):
     snapshot_metadata = Table('snapshot_metadata',
                               meta,
                               autoload=True)
-    try:
-        snapshot_metadata.drop()
-    except Exception:
-        LOG.error(_LE("snapshot_metadata table not dropped"))
-        raise
+    snapshot_metadata.drop()
index d0ef39c5df884f1e3c374f009c9f739b751d23c5..7207423e35cf7292884333aa9b532c7e46b1bf00 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import MetaData, String, Table, ForeignKey
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -43,11 +38,7 @@ def upgrade(migrate_engine):
         mysql_charset='utf8'
     )
 
-    try:
-        transfers.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(transfers))
-        raise
+    transfers.create()
 
 
 def downgrade(migrate_engine):
@@ -56,8 +47,4 @@ def downgrade(migrate_engine):
     transfers = Table('transfers',
                       meta,
                       autoload=True)
-    try:
-        transfers.drop()
-    except Exception:
-        LOG.error(_LE("transfers table not dropped"))
-        raise
+    transfers.drop()
index 3ae81aa6dfe38a47b9c7d65b014e2875d99cfa1d..86503ef29b54930b578d265dbc91e0f923059d3d 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime, Integer
 from sqlalchemy import MetaData, String, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 TABLE_NAME = 'migrations'
 
@@ -26,11 +21,7 @@ def upgrade(migrate_engine):
     meta = MetaData()
     meta.bind = migrate_engine
     table = Table(TABLE_NAME, meta, autoload=True)
-    try:
-        table.drop()
-    except Exception:
-        LOG.error(_LE("migrations table not dropped"))
-        raise
+    table.drop()
 
 
 def downgrade(migrate_engine):
@@ -56,8 +47,4 @@ def downgrade(migrate_engine):
         mysql_charset='utf8'
     )
 
-    try:
-        table.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created"), repr(table))
-        raise
+    table.create()
index 62a84d6201e53c89cc9837b221a686051ea57641..d242a408282464d56d939692e8a95f7e97eadf8d 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime, ForeignKey
 from sqlalchemy import Integer, MetaData, String, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -32,12 +27,7 @@ def upgrade(migrate_engine):
     tables = [sm_volume, sm_backend_config, sm_flavors]
 
     for table in tables:
-        try:
-            table.drop()
-        except Exception:
-            LOG.exception(_LE('Exception while dropping table %s.'),
-                          repr(table))
-            raise
+        table.drop()
 
 
 def downgrade(migrate_engine):
@@ -95,9 +85,4 @@ def downgrade(migrate_engine):
     tables = [sm_flavors, sm_backend_config, sm_volume]
 
     for table in tables:
-        try:
-            table.create()
-        except Exception:
-            LOG.exception(_LE('Exception while creating table %s.'),
-                          repr(table))
-            raise
+        table.create()
index 8659ea8e38cb1c77ff0e3340153a5d31412069c6..32669994a62ad53c9fbae621b44839882493574e 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column, ForeignKey, MetaData, Table
 from sqlalchemy import Boolean, DateTime, Integer, String
 
-from cinder.i18n import _LE
-
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData(bind=migrate_engine)
@@ -29,26 +23,14 @@ def upgrade(migrate_engine):
     # encryption key UUID -- must be stored per volume
     volumes = Table('volumes', meta, autoload=True)
     encryption_key = Column('encryption_key_id', String(36))
-    try:
-        volumes.create_column(encryption_key)
-    except Exception:
-        LOG.error(_LE("Column |%s| not created!"), repr(encryption_key))
-        raise
+    volumes.create_column(encryption_key)
 
     # encryption key UUID and volume type id -- must be stored per snapshot
     snapshots = Table('snapshots', meta, autoload=True)
     encryption_key = Column('encryption_key_id', String(36))
-    try:
-        snapshots.create_column(encryption_key)
-    except Exception:
-        LOG.error(_LE("Column |%s| not created!"), repr(encryption_key))
-        raise
+    snapshots.create_column(encryption_key)
     volume_type = Column('volume_type_id', String(36))
-    try:
-        snapshots.create_column(volume_type)
-    except Exception:
-        LOG.error(_LE("Column |%s| not created!"), repr(volume_type))
-        raise
+    snapshots.create_column(volume_type)
 
     volume_types = Table('volume_types', meta, autoload=True)
 
@@ -75,11 +57,7 @@ def upgrade(migrate_engine):
         mysql_charset='utf8'
     )
 
-    try:
-        encryption.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(encryption))
-        raise
+    encryption.create()
 
 
 def downgrade(migrate_engine):
@@ -87,29 +65,13 @@ def downgrade(migrate_engine):
 
     # drop encryption key UUID for volumes
     volumes = Table('volumes', meta, autoload=True)
-    try:
-        volumes.c.encryption_key_id.drop()
-    except Exception:
-        LOG.error(_LE("encryption_key_id column not dropped from volumes"))
-        raise
+    volumes.c.encryption_key_id.drop()
 
     # drop encryption key UUID and volume type id for snapshots
     snapshots = Table('snapshots', meta, autoload=True)
-    try:
-        snapshots.c.encryption_key_id.drop()
-    except Exception:
-        LOG.error(_LE("encryption_key_id column not dropped from snapshots"))
-        raise
-    try:
-        snapshots.c.volume_type_id.drop()
-    except Exception:
-        LOG.error(_LE("volume_type_id column not dropped from snapshots"))
-        raise
+    snapshots.c.encryption_key_id.drop()
+    snapshots.c.volume_type_id.drop()
 
     # drop encryption types table
     encryption = Table('encryption', meta, autoload=True)
-    try:
-        encryption.drop()
-    except Exception:
-        LOG.error(_LE("encryption table not dropped"))
-        raise
+    encryption.drop()
index 1ca1d9fdcc38a81bd070a42e85b36d72fd07d8b6..238ee70f651945f0ced5197e8ae01afd2ac391e2 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import ForeignKey, MetaData, String, Table
 from migrate import ForeignKeyConstraint
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     """Add volume_type_rate_limit table."""
@@ -44,23 +39,14 @@ def upgrade(migrate_engine):
         mysql_charset='utf8'
     )
 
-    try:
-        quality_of_service_specs.create()
-    except Exception:
-        LOG.error(_LE("Table quality_of_service_specs not created!"))
-        raise
+    quality_of_service_specs.create()
 
     volume_types = Table('volume_types', meta, autoload=True)
     qos_specs_id = Column('qos_specs_id', String(36),
                           ForeignKey('quality_of_service_specs.id'))
 
-    try:
-        volume_types.create_column(qos_specs_id)
-        volume_types.update().values(qos_specs_id=None).execute()
-    except Exception:
-        LOG.error(_LE("Added qos_specs_id column to volume type table "
-                      "failed."))
-        raise
+    volume_types.create_column(qos_specs_id)
+    volume_types.update().values(qos_specs_id=None).execute()
 
 
 def downgrade(migrate_engine):
@@ -80,24 +66,11 @@ def downgrade(migrate_engine):
                   'refcolumns': [ref_table.c['id']],
                   'name': 'volume_types_ibfk_1'}
 
-        try:
-            fkey = ForeignKeyConstraint(**params)
-            fkey.drop()
-        except Exception:
-            LOG.error(_LE("Dropping foreign key volume_types_ibfk_1 failed"))
+        fkey = ForeignKeyConstraint(**params)
+        fkey.drop()
 
     volume_types = Table('volume_types', meta, autoload=True)
     qos_specs_id = Column('qos_specs_id', String(36))
 
-    try:
-        volume_types.drop_column(qos_specs_id)
-    except Exception:
-        LOG.error(_LE("Dropping qos_specs_id column failed."))
-        raise
-
-    try:
-        qos_specs.drop()
-
-    except Exception:
-        LOG.error(_LE("Dropping quality_of_service_specs table failed."))
-        raise
+    volume_types.drop_column(qos_specs_id)
+    qos_specs.drop()
index 0eb95b37406480a3826167b5fe2550271e1e5800..96543879bb1093683c38e362b6eb72edc23d5995 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -41,11 +36,7 @@ def upgrade(migrate_engine):
         mysql_charset='utf8'
     )
 
-    try:
-        volume_admin_metadata.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(volume_admin_metadata))
-        raise
+    volume_admin_metadata.create()
 
 
 def downgrade(migrate_engine):
@@ -54,8 +45,4 @@ def downgrade(migrate_engine):
     volume_admin_metadata = Table('volume_admin_metadata',
                                   meta,
                                   autoload=True)
-    try:
-        volume_admin_metadata.drop()
-    except Exception:
-        LOG.error(_LE("volume_admin_metadata table not dropped"))
-        raise
+    volume_admin_metadata.drop()
index f7fc514a52d7fd959e3b80d9c3b97a0d2c8a549c..96785d08d16e745058e64598128bad67a1f7c7df 100644 (file)
 import datetime
 
 from oslo_config import cfg
-from oslo_log import log as logging
 from sqlalchemy import MetaData, Table
 
-from cinder.i18n import _LE, _LI
-
 # Get default values via config.  The defaults will either
 # come from the default values set in the quota option
 # configuration or via cinder.conf if the user has configured
@@ -28,7 +25,6 @@ CONF = cfg.CONF
 CONF.import_opt('quota_volumes', 'cinder.quota')
 CONF.import_opt('quota_snapshots', 'cinder.quota')
 CONF.import_opt('quota_gigabytes', 'cinder.quota')
-LOG = logging.getLogger(__name__)
 
 CLASS_NAME = 'default'
 CREATED_AT = datetime.datetime.now()  # noqa
@@ -47,34 +43,27 @@ def upgrade(migrate_engine):
     # Do not add entries if there are already 'default' entries.  We don't
     # want to write over something the user added.
     if rows:
-        LOG.info(_LI("Found existing 'default' entries in the quota_classes "
-                     "table.  Skipping insertion of default values."))
         return
 
-    try:
-        # Set default volumes
-        qci = quota_classes.insert()
-        qci.execute({'created_at': CREATED_AT,
-                     'class_name': CLASS_NAME,
-                     'resource': 'volumes',
-                     'hard_limit': CONF.quota_volumes,
-                     'deleted': False, })
-        # Set default snapshots
-        qci.execute({'created_at': CREATED_AT,
-                     'class_name': CLASS_NAME,
-                     'resource': 'snapshots',
-                     'hard_limit': CONF.quota_snapshots,
-                     'deleted': False, })
-        # Set default gigabytes
-        qci.execute({'created_at': CREATED_AT,
-                     'class_name': CLASS_NAME,
-                     'resource': 'gigabytes',
-                     'hard_limit': CONF.quota_gigabytes,
-                     'deleted': False, })
-        LOG.info(_LI("Added default quota class data into the DB."))
-    except Exception:
-        LOG.error(_LE("Default quota class data not inserted into the DB."))
-        raise
+    # Set default volumes
+    qci = quota_classes.insert()
+    qci.execute({'created_at': CREATED_AT,
+                 'class_name': CLASS_NAME,
+                 'resource': 'volumes',
+                 'hard_limit': CONF.quota_volumes,
+                 'deleted': False, })
+    # Set default snapshots
+    qci.execute({'created_at': CREATED_AT,
+                 'class_name': CLASS_NAME,
+                 'resource': 'snapshots',
+                 'hard_limit': CONF.quota_snapshots,
+                 'deleted': False, })
+    # Set default gigabytes
+    qci.execute({'created_at': CREATED_AT,
+                 'class_name': CLASS_NAME,
+                 'resource': 'gigabytes',
+                 'hard_limit': CONF.quota_gigabytes,
+                 'deleted': False, })
 
 
 def downgrade(migrate_engine):
index 71000ef20052acede969382877dbdeebcca4ae89..b82beb13ee506f65c0b1cc059e9dc39fcd017fc9 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Index, MetaData, Table
 
-from cinder.i18n import _LI
-
-LOG = logging.getLogger(__name__)
-
 
 def _get_deleted_expire_index(table):
     members = sorted(['deleted', 'expire'])
@@ -33,8 +28,6 @@ def upgrade(migrate_engine):
 
     reservations = Table('reservations', meta, autoload=True)
     if _get_deleted_expire_index(reservations):
-        LOG.info(_LI('Skipped adding reservations_deleted_expire_idx '
-                     'because an equivalent index already exists.'))
         return
 
     # Based on expire_reservations query
@@ -54,6 +47,3 @@ def downgrade(migrate_engine):
     index = _get_deleted_expire_index(reservations)
     if index:
         index.drop(migrate_engine)
-    else:
-        LOG.info(_LI('Skipped removing reservations_deleted_expire_idx '
-                     'because index does not exist.'))
index 2a06b01bbc05e23c76bff483ad35cc8587f31aa4..4e5021ba3e529ae968503a3bfac799a4d5a21f77 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column
 from sqlalchemy import MetaData, String, Table
 
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     """Add replication columns to volumes."""
index 5aea1a09158ccd9df1733d63ff32832917616bac..5ca70fbb5c1c1896105417727081bb6f238f622f 100644 (file)
 #    under the License.
 
 from migrate import ForeignKeyConstraint
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import ForeignKey, MetaData, String, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -47,11 +42,7 @@ def upgrade(migrate_engine):
         mysql_charset='utf8',
     )
 
-    try:
-        consistencygroups.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(consistencygroups))
-        raise
+    consistencygroups.create()
 
     # New table
     cgsnapshots = Table(
@@ -73,36 +64,22 @@ def upgrade(migrate_engine):
         mysql_charset='utf8',
     )
 
-    try:
-        cgsnapshots.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(cgsnapshots))
-        raise
+    cgsnapshots.create()
 
     # Add column to volumes table
     volumes = Table('volumes', meta, autoload=True)
     consistencygroup_id = Column('consistencygroup_id', String(36),
                                  ForeignKey('consistencygroups.id'))
-    try:
-        volumes.create_column(consistencygroup_id)
-        volumes.update().values(consistencygroup_id=None).execute()
-    except Exception:
-        LOG.error(_LE("Adding consistencygroup_id column to volumes table"
-                      " failed."))
-        raise
+    volumes.create_column(consistencygroup_id)
+    volumes.update().values(consistencygroup_id=None).execute()
 
     # Add column to snapshots table
     snapshots = Table('snapshots', meta, autoload=True)
     cgsnapshot_id = Column('cgsnapshot_id', String(36),
                            ForeignKey('cgsnapshots.id'))
 
-    try:
-        snapshots.create_column(cgsnapshot_id)
-        snapshots.update().values(cgsnapshot_id=None).execute()
-    except Exception:
-        LOG.error(_LE("Adding cgsnapshot_id column to snapshots table"
-                      " failed."))
-        raise
+    snapshots.create_column(cgsnapshot_id)
+    snapshots.update().values(cgsnapshot_id=None).execute()
 
 
 def downgrade(migrate_engine):
@@ -120,12 +97,8 @@ def downgrade(migrate_engine):
                   'refcolumns': [ref_table.c['id']],
                   'name': 'snapshots_ibfk_1'}
 
-        try:
-            fkey = ForeignKeyConstraint(**params)
-            fkey.drop()
-        except Exception:
-            LOG.error(_LE("Dropping foreign key 'cgsnapshot_id' in "
-                          "the 'snapshots' table failed."))
+        fkey = ForeignKeyConstraint(**params)
+        fkey.drop()
 
     snapshots = Table('snapshots', meta, autoload=True)
     cgsnapshot_id = snapshots.columns.cgsnapshot_id
@@ -142,12 +115,8 @@ def downgrade(migrate_engine):
                   'refcolumns': [ref_table.c['id']],
                   'name': 'volumes_ibfk_1'}
 
-        try:
-            fkey = ForeignKeyConstraint(**params)
-            fkey.drop()
-        except Exception:
-            LOG.error(_LE("Dropping foreign key 'consistencygroup_id' in "
-                          "the 'volumes' table failed."))
+        fkey = ForeignKeyConstraint(**params)
+        fkey.drop()
 
     volumes = Table('volumes', meta, autoload=True)
     consistencygroup_id = volumes.columns.consistencygroup_id
@@ -155,16 +124,8 @@ def downgrade(migrate_engine):
 
     # Drop table
     cgsnapshots = Table('cgsnapshots', meta, autoload=True)
-    try:
-        cgsnapshots.drop()
-    except Exception:
-        LOG.error(_LE("cgsnapshots table not dropped"))
-        raise
+    cgsnapshots.drop()
 
     # Drop table
     consistencygroups = Table('consistencygroups', meta, autoload=True)
-    try:
-        consistencygroups.drop()
-    except Exception:
-        LOG.error(_LE("consistencygroups table not dropped"))
-        raise
+    consistencygroups.drop()
index 5b3c5307d516b25710514accfd28acb581c9b97a..7bc6609648111a96aaba2cb61fc5720d6f280b3a 100644 (file)
 import datetime
 
 from oslo_config import cfg
-from oslo_log import log as logging
 from sqlalchemy import MetaData, Table
 
-from cinder.i18n import _LE, _LI
-
 # Get default values via config.  The defaults will either
 # come from the default values set in the quota option
 # configuration or via cinder.conf if the user has configured
 # default values for quotas there.
 CONF = cfg.CONF
 CONF.import_opt('quota_consistencygroups', 'cinder.quota')
-LOG = logging.getLogger(__name__)
 
 CLASS_NAME = 'default'
 CREATED_AT = datetime.datetime.now()  # noqa
@@ -45,24 +41,15 @@ def upgrade(migrate_engine):
 
     # Do not add entries if there are already 'consistencygroups' entries.
     if rows:
-        LOG.info(_LI("Found existing 'consistencygroups' entries in the "
-                     "quota_classes table.  Skipping insertion."))
         return
 
-    try:
-        # Set consistencygroups
-        qci = quota_classes.insert()
-        qci.execute({'created_at': CREATED_AT,
-                     'class_name': CLASS_NAME,
-                     'resource': 'consistencygroups',
-                     'hard_limit': CONF.quota_consistencygroups,
-                     'deleted': False, })
-        LOG.info(_LI("Added default consistencygroups quota class data into "
-                     "the DB."))
-    except Exception:
-        LOG.error(_LE("Default consistencygroups quota class data not "
-                      "inserted into the DB."))
-        raise
+    # Set consistencygroups
+    qci = quota_classes.insert()
+    qci.execute({'created_at': CREATED_AT,
+                 'class_name': CLASS_NAME,
+                 'resource': 'consistencygroups',
+                 'hard_limit': CONF.quota_consistencygroups,
+                 'deleted': False, })
 
 
 def downgrade(migrate_engine):
index 41846646f3220a95a57c64a157e00992f81f7891..99cb5a32271705226ec933858f59efe1df273ff4 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Boolean, Column, DateTime, UniqueConstraint
 from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -25,13 +20,9 @@ def upgrade(migrate_engine):
     volume_types = Table('volume_types', meta, autoload=True)
     is_public = Column('is_public', Boolean)
 
-    try:
-        volume_types.create_column(is_public)
-        # pylint: disable=E1120
-        volume_types.update().values(is_public=True).execute()
-    except Exception:
-        LOG.error(_LE("Column |%s| not created!"), repr(is_public))
-        raise
+    volume_types.create_column(is_public)
+    # pylint: disable=E1120
+    volume_types.update().values(is_public=True).execute()
 
     volume_type_projects = Table(
         'volume_type_projects', meta,
@@ -47,11 +38,7 @@ def upgrade(migrate_engine):
         mysql_engine='InnoDB',
     )
 
-    try:
-        volume_type_projects.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(volume_type_projects))
-        raise
+    volume_type_projects.create()
 
 
 def downgrade(migrate_engine):
@@ -60,15 +47,7 @@ def downgrade(migrate_engine):
 
     volume_types = Table('volume_types', meta, autoload=True)
     is_public = volume_types.columns.is_public
-    try:
-        volume_types.drop_column(is_public)
-    except Exception:
-        LOG.error(_LE("volume_types.is_public column not dropped"))
-        raise
+    volume_types.drop_column(is_public)
 
     volume_type_projects = Table('volume_type_projects', meta, autoload=True)
-    try:
-        volume_type_projects.drop()
-    except Exception:
-        LOG.error(_LE("volume_type_projects table not dropped"))
-        raise
+    volume_type_projects.drop()
index 237389c1437a3b8873145fb02210812fce0faab7..f9b595748e5ec8a7b7e4a75550aaa5faaba0769f 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column
 from sqlalchemy import MetaData, String, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     """Add cgsnapshot_id column to consistencygroups."""
@@ -27,13 +22,8 @@ def upgrade(migrate_engine):
     consistencygroups = Table('consistencygroups', meta, autoload=True)
     cgsnapshot_id = Column('cgsnapshot_id', String(36))
 
-    try:
-        consistencygroups.create_column(cgsnapshot_id)
-        consistencygroups.update().values(cgsnapshot_id=None).execute()
-    except Exception:
-        LOG.error(_LE("Adding cgsnapshot_id column to consistencygroups "
-                      "table failed."))
-        raise
+    consistencygroups.create_column(cgsnapshot_id)
+    consistencygroups.update().values(cgsnapshot_id=None).execute()
 
 
 def downgrade(migrate_engine):
@@ -44,9 +34,4 @@ def downgrade(migrate_engine):
     consistencygroups = Table('consistencygroups', meta, autoload=True)
     cgsnapshot_id = consistencygroups.columns.cgsnapshot_id
 
-    try:
-        consistencygroups.drop_column(cgsnapshot_id)
-    except Exception:
-        LOG.error(_LE("Dropping cgsnapshot_id column from consistencygroups "
-                      "table failed."))
-        raise
+    consistencygroups.drop_column(cgsnapshot_id)
index dc3cfb94404da01de4582157c22669184d5bf8ce..da029bbeab6d79c96c38c9157c41d3fc77502718 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column, DateTime, Integer
 from sqlalchemy import MetaData, String, Table, UniqueConstraint
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -38,11 +33,7 @@ def upgrade(migrate_engine):
         mysql_charset='utf8'
     )
 
-    try:
-        initiator_data.create()
-    except Exception:
-        LOG.error(_LE("Table |%s| not created!"), repr(initiator_data))
-        raise
+    initiator_data.create()
 
 
 def downgrade(migrate_engine):
@@ -50,9 +41,4 @@ def downgrade(migrate_engine):
     meta.bind = migrate_engine
     table_name = 'driver_initiator_data'
     initiator_data = Table(table_name, meta, autoload=True)
-    try:
-        initiator_data.drop()
-    except Exception:
-        LOG.error(_LE("%(table_name)s table not dropped"),
-                  {'table_name': table_name})
-        raise
+    initiator_data.drop()
index c8374e7c293e71c73b35a5e8616e46e29deb107f..0ffddb5e81f1728fec0fec0eb877ce139dc53e3e 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column, MetaData, String, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
@@ -29,12 +24,8 @@ def upgrade(migrate_engine):
     backups = Table('backups', meta, autoload=True)
     parent_id = Column('parent_id', String(length=36))
 
-    try:
-        backups.create_column(parent_id)
-        backups.update().values(parent_id=None).execute()
-    except Exception:
-        LOG.error(_LE("Adding parent_id column to backups table failed."))
-        raise
+    backups.create_column(parent_id)
+    backups.update().values(parent_id=None).execute()
 
 
 def downgrade(migrate_engine):
@@ -44,8 +35,4 @@ def downgrade(migrate_engine):
     backups = Table('backups', meta, autoload=True)
     parent_id = backups.columns.parent_id
 
-    try:
-        backups.drop_column(parent_id)
-    except Exception:
-        LOG.error(_LE("Dropping parent_id column from backups table failed."))
-        raise
+    backups.drop_column(parent_id)
index 237da2e1a46104214bb1569f07d27d0817892df5..f51b8fd42e8ca8b22878811d552e686763f30296 100644 (file)
 import datetime
 import uuid
 
-from oslo_log import log as logging
 import six
 from sqlalchemy import Boolean, Column, DateTime
 from sqlalchemy import ForeignKey, MetaData, String, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 CREATED_AT = datetime.datetime.now()  # noqa
 
 
@@ -59,11 +54,7 @@ def upgrade(migrate_engine):
         mysql_engine='InnoDB'
     )
 
-    try:
-        volume_attachment.create()
-    except Exception:
-        LOG.error(_LE("Table volume_attachment not created!"))
-        raise
+    volume_attachment.create()
 
     # now migrate existing volume attachment info into the
     # new volume_attachment table
@@ -139,9 +130,4 @@ def downgrade(migrate_engine):
                        attach_time=attachment.attach_time,
                        instance_uuid=attachment.instance_uuid).\
                 execute()
-    try:
-        volume_attachment.drop()
-
-    except Exception:
-        LOG.error(_LE("Dropping volume_attachment table failed."))
-        raise
+    volume_attachment.drop()
index be2d33e0978411ea8128d3b579deea296c2751ee..10d1750ae93aa97772a61d9f1a081cd66bb7fa8c 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from sqlalchemy import Column, MetaData, DateTime, Table
 
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     meta = MetaData()
     meta.bind = migrate_engine
     services = Table('services', meta, autoload=True)
     modified_at = Column('modified_at', DateTime(timezone=False))
-    try:
-        services.create_column(modified_at)
-    except Exception:
-        LOG.error(_LE("Adding modified_at column to services table failed."))
-        raise
+    services.create_column(modified_at)
 
 
 def downgrade(migrate_engine):
     meta = MetaData()
     meta.bind = migrate_engine
     services = Table('services', meta, autoload=True)
-    try:
-        services.drop_column('modified_at')
-    except Exception:
-        LOG.error(_LE("Unable to drop modified_at column from services"
-                  "table."))
-        raise
+    services.drop_column('modified_at')
index a4a0e87c48ac9d5cc6f6f3e246706bdba51facb7..6881efb37241801d749c0110c74aa8f1aa154b19 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from oslo_log import log as logging
 from oslo_utils import timeutils
 from sqlalchemy import MetaData, Table
 
-from cinder.i18n import _LE
 
 # Get default value via config. The default will either
 # come from the default value set in the quota configuration option
 # or via cinder.conf if the user has configured
 # default value for per volume size limit there.
 
-LOG = logging.getLogger(__name__)
-
 
 def upgrade(migrate_engine):
     """Add default "per_volume_gigabytes" row into DB."""
@@ -39,18 +35,13 @@ def upgrade(migrate_engine):
     if row:
         return
 
-    try:
-        # Set default per_volume_gigabytes for per volume size
-        qci = quota_classes.insert()
-        qci.execute({'created_at': timeutils.utcnow(),
-                     'class_name': 'default',
-                     'resource': 'per_volume_gigabytes',
-                     'hard_limit': -1,
-                     'deleted': False, })
-    except Exception:
-        LOG.error(_LE("Default per_volume_gigabytes row not inserted "
-                      "into the quota_classes."))
-        raise
+    # Set default per_volume_gigabytes for per volume size
+    qci = quota_classes.insert()
+    qci.execute({'created_at': timeutils.utcnow(),
+                 'class_name': 'default',
+                 'resource': 'per_volume_gigabytes',
+                 'hard_limit': -1,
+                 'deleted': False, })
 
 
 def downgrade(migrate_engine):