From 5e489f475f4fe0529280f419b4708aa22c13ad39 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Tue, 15 Oct 2013 13:57:48 -0600 Subject: [PATCH] FK lookup failures during migration There are a couple of cases where migrations have failed upgrading from Grizzly to Havana, this seems to be isolated to a couple of migrations so far and the error message is a failure to lookup/associate the volume-id FK dependency. It appears that this is caused by not setting the charset in the migration, so the result is that the initial db setup uses utf8 and the migrations are using the default latin1. This patch goes through all of the migrations in Havana that specify InnoDB and explicitly sets the charset to utf8 to match the volumes table (and the other original tables). Change-Id: I43b219ff5e4eea10a7391ad65ef68a80b7460370 Closes-Bug: #1233861 (cherry picked from commit 645a84f990c90e28548cf35b4b5f242eb0e0c286) --- .../migrate_repo/versions/010_add_transfers_table.py | 3 ++- .../migrate_repo/versions/015_drop_migrations_table.py | 3 ++- .../migrate_repo/versions/016_drop_sm_tables.py | 9 ++++++--- .../versions/017_add_encryption_information.py | 3 ++- .../migrate_repo/versions/018_add_qos_specs.py | 3 ++- .../versions/020_add_volume_admin_metadata_table.py | 3 ++- 6 files changed, 16 insertions(+), 8 deletions(-) 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 781a44370..26b4bd6b2 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 @@ -40,7 +40,8 @@ def upgrade(migrate_engine): Column('salt', String(length=255)), Column('crypt_hash', String(length=255)), Column('expires_at', DateTime(timezone=False)), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) try: 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 2de50be94..75627b371 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 @@ -53,7 +53,8 @@ def downgrade(migrate_engine): Column('new_instance_type_id', Integer), Column('instance_uuid', String(length=255), nullable=True), Column('status', String(length=255)), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) try: 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 0ad1fafc8..2dabaa51a 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 @@ -59,7 +59,8 @@ def downgrade(migrate_engine): Column('sr_uuid', String(length=255)), Column('sr_type', String(length=255)), Column('config_params', String(length=2047)), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) sm_flavors = Table( @@ -71,7 +72,8 @@ def downgrade(migrate_engine): Column('id', Integer, primary_key=True, nullable=False), Column('label', String(length=255)), Column('description', String(length=255)), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) sm_volume = Table( @@ -87,7 +89,8 @@ def downgrade(migrate_engine): Column('backend_id', Integer, ForeignKey('sm_backend_config.id'), nullable=False), Column('vdi_uuid', String(length=255)), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) tables = [sm_flavors, sm_backend_config, sm_volume] 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 6b80969d1..df4347101 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 @@ -74,7 +74,8 @@ def upgrade(migrate_engine): Column('volume_type_id', String(length=36), ForeignKey(volume_types.c.id), primary_key=True, nullable=False), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) try: 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 a67b58744..c5fbe73be 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 @@ -40,7 +40,8 @@ def upgrade(migrate_engine): ForeignKey('quality_of_service_specs.id')), Column('key', String(255)), Column('value', String(255)), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) try: 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 f59c5c88c..0cfe9ae42 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 @@ -38,7 +38,8 @@ def upgrade(migrate_engine): nullable=False), Column('key', String(length=255)), Column('value', String(length=255)), - mysql_engine='InnoDB' + mysql_engine='InnoDB', + mysql_charset='utf8' ) try: -- 2.45.2