summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-03-13 21:53:12 +0000
committerGerrit Code Review <review@openstack.org>2013-03-13 21:53:12 +0000
commitf5198513215bfdc7026c5494ec11f09736e4a15e (patch)
treefa6e5d823cf79e203e2711caf9fef84904d2add3
parente47d099d383229bc9219b18e6c624657a2e76cdc (diff)
parent4814280ce0af71ad38155d07eefea7c762935fa7 (diff)
downloadnova-f5198513215bfdc7026c5494ec11f09736e4a15e.tar.gz
nova-f5198513215bfdc7026c5494ec11f09736e4a15e.tar.xz
nova-f5198513215bfdc7026c5494ec11f09736e4a15e.zip
Merge "Make run_instance() bail quietly if instance has been deleted"
-rwxr-xr-xnova/compute/manager.py11
-rw-r--r--nova/tests/compute/test_compute.py13
2 files changed, 22 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index e19059542..3631d2995 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -742,6 +742,15 @@ class ComputeManager(manager.SchedulerDependentManager):
try:
self._check_instance_exists(context, instance)
+
+ try:
+ self._start_building(context, instance)
+ except exception.InstanceNotFound:
+ LOG.info(_("Instance disappeared before we could start it"),
+ instance=instance)
+ # Quickly bail out of here
+ return
+
image_meta = self._check_image_size(context, instance)
if node is None:
@@ -754,8 +763,6 @@ class ComputeManager(manager.SchedulerDependentManager):
else:
extra_usage_info = {}
- self._start_building(context, instance)
-
self._notify_about_instance_usage(
context, instance, "create.start",
extra_usage_info=extra_usage_info)
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index f8c0e86f2..fd205c109 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -708,6 +708,19 @@ class ComputeTestCase(BaseTestCase):
self.compute.run_instance,
self.context, instance=instance)
+ def test_run_instance_bails_on_missing_instance(self):
+ # Make sure that run_instance() will quickly ignore a deleted instance
+ called = {}
+ instance = self._create_instance()
+
+ def fake_instance_update(self, *a, **args):
+ called['instance_update'] = True
+ raise exception.InstanceNotFound(instance_id='foo')
+ self.stubs.Set(self.compute, '_instance_update', fake_instance_update)
+
+ self.compute.run_instance(self.context, instance)
+ self.assertIn('instance_update', called)
+
def test_can_terminate_on_error_state(self):
# Make sure that the instance can be terminated in ERROR state.
#check failed to schedule --> terminate