summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-09-19 21:07:53 +0000
committerJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-09-19 21:55:50 +0000
commit66c34275f2defe94e68669fe4df1c4ea1830f720 (patch)
tree1b4afd0fb0df821779cec7c2b45eed34acf3ec5d /nova/compute
parent51cc814e435973ab2c150fddf8fda6d08ad03547 (diff)
Clean up test_state_revert
While the test is simply to ensure that the state is reverted, no matter what the failure, it did so a bit bluntly. The use of Exception on both the raising side and the catching side ended up masking a variety of other unintended failures. stop_instance and start_instance had bugs (fixed in parent patch) which ended up raising a KeyError exception. This still ended up resetting the state correctly because only the nested call to the decorator did not use the keyword argument for instance. rebuild_instance, revert_resize, prep_resize and resize_instance all required multiple extra arguments that weren't passed. This raised a TypeError exception. revert_resize and resize_instance also required an elevated context or nova.db.api.migration_get() would raise a exception.AdminRequired exception. Even with these unintended problems, the test still performed it's intended purpose, to test that task state is reverted. However, the use of Exception makes auditing the test harder. Change-Id: I5150957375ab3e57e7971f5e15daba531bb58803
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 6088ba5e6..f8d07d92b 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1409,6 +1409,7 @@ class ComputeManager(manager.SchedulerDependentManager):
source machine.
"""
+ context = context.elevated()
migration_ref = self.db.migration_get(context, migration_id)
with self._error_out_instance_on_exception(context, instance['uuid'],
reservations):
@@ -1543,6 +1544,7 @@ class ComputeManager(manager.SchedulerDependentManager):
def resize_instance(self, context, instance,
migration_id, image, reservations=None):
"""Starts the migration of a running instance to another host."""
+ context = context.elevated()
migration_ref = self.db.migration_get(context, migration_id)
with self._error_out_instance_on_exception(context, instance['uuid'],
reservations):