summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2012-11-14 17:25:43 +0000
committerChris Behrens <cbehrens@codestud.com>2012-11-14 17:30:17 +0000
commit9fdf7552779d518af9cda4e366bf81fddb0cb6f2 (patch)
tree8a8eb929a580d62ed2347253af201a754684ae46 /nova/db
parent16266a4afbfdbed5e3c2334e03e2c9c43b133020 (diff)
Make sure instance data is always refreshed
Fixes bug 1078793 When updating an instance's instance_type_id, the 'instance_type' joined to the instance is not updated. This updates that. A DB API test is added that failed before and passes now. Also: Some cases of passing stale instance data within resize_instance() and finish_resize() were found and addressed. Change-Id: If335cc286a71597d3100425080e51c75aeec7a50
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/sqlalchemy/api.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 007e83cbe..3cba27c1e 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -1813,6 +1813,13 @@ def _instance_update(context, instance_uuid, values, copy_old_instance=False):
instance_ref.update(values)
instance_ref.save(session=session)
+ if 'instance_type_id' in values:
+ # NOTE(comstud): It appears that sqlalchemy doesn't refresh
+ # the instance_type model after you update the ID. You end
+ # up with an instance_type model that only has 'id' updated,
+ # but the rest of the model has the data from the old
+ # instance_type.
+ session.refresh(instance_ref['instance_type'])
return (old_instance_ref, instance_ref)