summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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