From: John Griffith Date: Mon, 15 Jun 2015 21:23:39 +0000 (-0600) Subject: Remove logging statements from migrations X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=82e87b5080fa539c3fe3f58b59dc7db0678ca3a3;p=openstack-build%2Fcinder-build.git Remove logging statements from migrations 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 --- diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py b/cinder/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py index 4666a9a79..a39aed63c 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/001_cinder_init.py @@ -12,15 +12,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py b/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py index 6d801e0f4..8d133ed80 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py @@ -13,14 +13,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py b/cinder/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py index 52e1a61d6..4c38c2dbe 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py @@ -12,14 +12,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py b/cinder/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py index 745cdf432..bbb6fa80c 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/004_volume_type_to_uuid.py @@ -13,13 +13,8 @@ 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 diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py b/cinder/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py index caf8b54ed..2315ad38c 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/005_add_source_volume_column.py @@ -10,12 +10,9 @@ # 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.""" diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py b/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py index 9a899f37d..9b50c89b7 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py @@ -13,14 +13,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py index 7c33382c8..86596db1a 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py @@ -10,14 +10,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/010_add_transfers_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/010_add_transfers_table.py index d0ef39c5d..7207423e3 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/010_add_transfers_table.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/010_add_transfers_table.py @@ -10,14 +10,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/015_drop_migrations_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/015_drop_migrations_table.py index 3ae81aa6d..86503ef29 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/015_drop_migrations_table.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/015_drop_migrations_table.py @@ -10,14 +10,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/016_drop_sm_tables.py b/cinder/db/sqlalchemy/migrate_repo/versions/016_drop_sm_tables.py index 62a84d620..d242a4082 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/016_drop_sm_tables.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/016_drop_sm_tables.py @@ -12,14 +12,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/017_add_encryption_information.py b/cinder/db/sqlalchemy/migrate_repo/versions/017_add_encryption_information.py index 8659ea8e3..32669994a 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/017_add_encryption_information.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/017_add_encryption_information.py @@ -13,15 +13,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/018_add_qos_specs.py b/cinder/db/sqlalchemy/migrate_repo/versions/018_add_qos_specs.py index 1ca1d9fdc..238ee70f6 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/018_add_qos_specs.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/018_add_qos_specs.py @@ -14,15 +14,10 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/020_add_volume_admin_metadata_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/020_add_volume_admin_metadata_table.py index 0eb95b374..96543879b 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/020_add_volume_admin_metadata_table.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/020_add_volume_admin_metadata_table.py @@ -10,14 +10,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/021_add_default_quota_class.py b/cinder/db/sqlalchemy/migrate_repo/versions/021_add_default_quota_class.py index f7fc514a5..96785d08d 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/021_add_default_quota_class.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/021_add_default_quota_class.py @@ -15,11 +15,8 @@ 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): 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 71000ef20..b82beb13e 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 @@ -12,13 +12,8 @@ # 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.')) diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/024_add_replication_support.py b/cinder/db/sqlalchemy/migrate_repo/versions/024_add_replication_support.py index 2a06b01bb..4e5021ba3 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/024_add_replication_support.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/024_add_replication_support.py @@ -12,12 +12,9 @@ # 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.""" diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/025_add_consistencygroup.py b/cinder/db/sqlalchemy/migrate_repo/versions/025_add_consistencygroup.py index 5aea1a091..5ca70fbb5 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/025_add_consistencygroup.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/025_add_consistencygroup.py @@ -14,14 +14,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/026_add_consistencygroup_quota_class.py b/cinder/db/sqlalchemy/migrate_repo/versions/026_add_consistencygroup_quota_class.py index 5b3c5307d..7bc660964 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/026_add_consistencygroup_quota_class.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/026_add_consistencygroup_quota_class.py @@ -15,18 +15,14 @@ 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): diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/032_add_volume_type_projects.py b/cinder/db/sqlalchemy/migrate_repo/versions/032_add_volume_type_projects.py index 41846646f..99cb5a322 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/032_add_volume_type_projects.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/032_add_volume_type_projects.py @@ -10,14 +10,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/037_add_cgsnapshot_id_column_to_consistencygroups.py b/cinder/db/sqlalchemy/migrate_repo/versions/037_add_cgsnapshot_id_column_to_consistencygroups.py index 237389c14..f9b595748 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/037_add_cgsnapshot_id_column_to_consistencygroups.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/037_add_cgsnapshot_id_column_to_consistencygroups.py @@ -10,14 +10,9 @@ # 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) diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/038_add_driver_initiator_data_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/038_add_driver_initiator_data_table.py index dc3cfb944..da029bbea 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/038_add_driver_initiator_data_table.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/038_add_driver_initiator_data_table.py @@ -10,14 +10,9 @@ # 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/039_add_parent_id_to_backups.py b/cinder/db/sqlalchemy/migrate_repo/versions/039_add_parent_id_to_backups.py index c8374e7c2..0ffddb5e8 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/039_add_parent_id_to_backups.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/039_add_parent_id_to_backups.py @@ -14,13 +14,8 @@ # 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) diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/040_add_volume_attachment.py b/cinder/db/sqlalchemy/migrate_repo/versions/040_add_volume_attachment.py index 237da2e1a..f51b8fd42 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/040_add_volume_attachment.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/040_add_volume_attachment.py @@ -16,15 +16,10 @@ 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() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/041_add_modified_at_column_to_service.py b/cinder/db/sqlalchemy/migrate_repo/versions/041_add_modified_at_column_to_service.py index be2d33e09..10d1750ae 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/041_add_modified_at_column_to_service.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/041_add_modified_at_column_to_service.py @@ -10,33 +10,19 @@ # 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') diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py b/cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py index a4a0e87c4..6881efb37 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py @@ -10,19 +10,15 @@ # 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):