summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2011-08-24 15:50:46 +0100
committerMark McLoughlin <markmc@redhat.com>2011-08-24 15:50:46 +0100
commitb428ac4c20e44f537b0dedeefcc2637efbc998ea (patch)
treeba24bb21d6fdd466c9d58ead0a2594642d42f0e7
parent0873a3c7b9a1a75c6e04bd1b66f8fbe4935585b2 (diff)
downloadnova-b428ac4c20e44f537b0dedeefcc2637efbc998ea.tar.gz
nova-b428ac4c20e44f537b0dedeefcc2637efbc998ea.tar.xz
nova-b428ac4c20e44f537b0dedeefcc2637efbc998ea.zip
Fix quotas migration failure
With sqlalchemy 0.7.2 and migrate 0.7.1, I was seeing: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/nova/db/migration.py", line 37, in db_sync ret = IMPL.db_sync(version=version) [..] File "/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py", line 189, in upgrade new_quotas.rename('quotas') [..] File "/usr/lib/python2.7/site-packages/migrate/changeset/schema.py", line 479, in deregister del meta.tables[key] File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/_collections.py", line 38, in _immutable raise TypeError("%s object is immutable" % self.__class__.__name__) TypeError: immutabledict object is immutable This is actually a bug in sqlalchemy-migrate: http://code.google.com/p/sqlalchemy-migrate/issues/detail?id=128 But it can be worked around by ensuring there isn't a 'quotas' table in the metadata's table hash before renaming.
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py
index a4fe3e482..56b287171 100644
--- a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py
+++ b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py
@@ -75,8 +75,8 @@ def new_style_quotas_table(name):
)
-def existing_quotas_table(migrate_engine):
- return Table('quotas', meta, autoload=True, autoload_with=migrate_engine)
+def quotas_table(migrate_engine, name='quotas'):
+ return Table(name, meta, autoload=True, autoload_with=migrate_engine)
def _assert_no_duplicate_project_ids(quotas):
@@ -179,13 +179,18 @@ def upgrade(migrate_engine):
# bind migrate_engine to your metadata
meta.bind = migrate_engine
- old_quotas = existing_quotas_table(migrate_engine)
+ old_quotas = quotas_table(migrate_engine)
assert_old_quotas_have_no_active_duplicates(migrate_engine, old_quotas)
new_quotas = new_style_quotas_table('quotas_new')
new_quotas.create()
convert_forward(migrate_engine, old_quotas, new_quotas)
old_quotas.drop()
+
+ # clear metadata to work around this:
+ # http://code.google.com/p/sqlalchemy-migrate/issues/detail?id=128
+ meta.clear()
+ new_quotas = quotas_table(migrate_engine, 'quotas_new')
new_quotas.rename('quotas')
@@ -193,11 +198,16 @@ def downgrade(migrate_engine):
# Operations to reverse the above upgrade go here.
meta.bind = migrate_engine
- new_quotas = existing_quotas_table(migrate_engine)
+ new_quotas = quotas_table(migrate_engine)
assert_new_quotas_have_no_active_duplicates(migrate_engine, new_quotas)
old_quotas = old_style_quotas_table('quotas_old')
old_quotas.create()
convert_backward(migrate_engine, old_quotas, new_quotas)
new_quotas.drop()
+
+ # clear metadata to work around this:
+ # http://code.google.com/p/sqlalchemy-migrate/issues/detail?id=128
+ meta.clear()
+ old_quotas = quotas_table(migrate_engine, 'quotas_old')
old_quotas.rename('quotas')