diff options
| author | Dan Smith <danms@us.ibm.com> | 2013-03-12 16:39:19 -0400 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2013-03-12 16:39:19 -0400 |
| commit | 4814280ce0af71ad38155d07eefea7c762935fa7 (patch) | |
| tree | 109f2d5a6e145d1174335f050458d191f51fa037 | |
| parent | f0fc1240090938ae9d945bb91bfeda4e5d42ac9c (diff) | |
| download | nova-4814280ce0af71ad38155d07eefea7c762935fa7.tar.gz nova-4814280ce0af71ad38155d07eefea7c762935fa7.tar.xz nova-4814280ce0af71ad38155d07eefea7c762935fa7.zip | |
Make run_instance() bail quietly if instance has been deleted
Right now, we make a big mess in the logs if someone deletes an
instance before we get a chance to run it. This cleans that up
to a single warning message.
Fixes bug 1154292
Change-Id: I2de0c2993d6a16d9482878eee4eef10bfd78c3e6
| -rwxr-xr-x | nova/compute/manager.py | 11 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 13 |
2 files changed, 22 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 53ab3a2ed..b2d69e6a7 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -747,6 +747,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: @@ -759,8 +768,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 0e41678b3..a3ce7bdae 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 |
