From 4814280ce0af71ad38155d07eefea7c762935fa7 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 12 Mar 2013 16:39:19 -0400 Subject: 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 --- nova/tests/compute/test_compute.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nova/tests') 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 -- cgit