From 9fdf7552779d518af9cda4e366bf81fddb0cb6f2 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 14 Nov 2012 17:25:43 +0000 Subject: 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 --- nova/db/sqlalchemy/api.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nova/db') 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) -- cgit