summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2013-03-11 13:13:11 -0400
committerDan Smith <danms@us.ibm.com>2013-03-11 13:13:11 -0400
commitd8d7d148fe2c185f2efda0c4cfc2ca125d4008d7 (patch)
tree5fbcf02449e2fbd38f11f2765403cad4eef4b312
parentf543f347c84e7f5de2c584ca55363e4dee5b0a3d (diff)
downloadnova-d8d7d148fe2c185f2efda0c4cfc2ca125d4008d7.tar.gz
nova-d8d7d148fe2c185f2efda0c4cfc2ca125d4008d7.tar.xz
nova-d8d7d148fe2c185f2efda0c4cfc2ca125d4008d7.zip
Pass migration_ref when when auto-confirming
The _poll_unconfirmed_resizes() task in compute/manager calls back to compute_api to confirm resizes. This triggers a db lookup for the migration, which is not allowed by no-db-compute. Since we already have the migration, pass it through to avoid the lookup. Since this doesn't change rpcapi (and thus, RPC clients should not know about this optional paramter), we don't need to bump the RPC version here. Fixes bug 1152792 Change-Id: I4bd3b0c88968ed7f64e7df0afa12e83009ee8ccf
-rw-r--r--nova/compute/api.py7
-rwxr-xr-xnova/compute/manager.py3
-rw-r--r--nova/tests/compute/test_compute.py6
3 files changed, 10 insertions, 6 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index dc90748a4..78667882a 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -1848,11 +1848,12 @@ class API(base.Base):
@wrap_check_policy
@check_instance_lock
@check_instance_state(vm_state=[vm_states.RESIZED])
- def confirm_resize(self, context, instance):
+ def confirm_resize(self, context, instance, migration_ref=None):
"""Confirms a migration/resize and deletes the 'old' instance."""
elevated = context.elevated()
- migration_ref = self.db.migration_get_by_instance_and_status(elevated,
- instance['uuid'], 'finished')
+ if migration_ref is None:
+ migration_ref = self.db.migration_get_by_instance_and_status(
+ elevated, instance['uuid'], 'finished')
# reserve quota only for any decrease in resource usage
deltas = self._downsize_quota_delta(context, migration_ref)
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 338708f4e..f1b0f6fe0 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -3322,7 +3322,8 @@ class ComputeManager(manager.SchedulerDependentManager):
instance=instance)
continue
try:
- self.compute_api.confirm_resize(context, instance)
+ self.compute_api.confirm_resize(context, instance,
+ migration_ref=migration)
except Exception, e:
msg = _("Error auto-confirming resize: %(e)s. "
"Will retry later.")
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index e94d8b788..0e41678b3 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -3414,13 +3414,15 @@ class ComputeTestCase(BaseTestCase):
if migration['id'] == m['id']:
migration['status'] = status
- def fake_confirm_resize(context, instance):
+ def fake_confirm_resize(context, instance, migration_ref=None):
# raise exception for 'fake_uuid4' to check migration status
# does not get set to 'error' on confirm_resize failure.
if instance['uuid'] == 'fake_uuid4':
raise test.TestingException
+ self.assertNotEqual(migration_ref, None)
for migration in migrations:
- if migration['instance_uuid'] == instance['uuid']:
+ if (migration['instance_uuid'] ==
+ migration_ref['instance_uuid']):
migration['status'] = 'confirmed'
self.stubs.Set(db, 'instance_get_by_uuid',