Fix run/terminate race conditions.
* synchronize run,terminate,stop,start on instance_uuid * don't surpress error when unfiltering instance, which can result in a zombified instance. * Fixes bug 956719 * Remove debug raise Change-Id: I8b2eaffdabfd5c1a9414adb1b5ed11e4c48711fc
This commit is contained in:
		| @@ -932,26 +932,21 @@ class ComputeTestCase(BaseTestCase): | |||||||
|  |  | ||||||
|         self.compute.terminate_instance(self.context, instance['uuid']) |         self.compute.terminate_instance(self.context, instance['uuid']) | ||||||
|  |  | ||||||
|     def test_instance_set_to_error_on_deleted_instance_doesnt_raise(self): |     def test_instance_termination_exception_sets_error(self): | ||||||
|         """Test that we don't raise InstanceNotFound when trying to set |         """Test that we handle InstanceTerminationFailure | ||||||
|         an instance to ERROR that has already been deleted from under us. |         which is propagated up from the underlying driver. | ||||||
|         The original exception should be re-raised. |  | ||||||
|         """ |         """ | ||||||
|         instance = self._create_fake_instance() |         instance = self._create_fake_instance() | ||||||
|         instance_uuid = instance['uuid'] |  | ||||||
|  |  | ||||||
|         def fake_allocate_network(context, instance, requested_networks): |         def fake_delete_instance(context, instance): | ||||||
|             # Remove the instance to simulate race condition |             raise exception.InstanceTerminationFailure(reason='') | ||||||
|  |  | ||||||
|  |         self.stubs.Set(self.compute, '_delete_instance', | ||||||
|  |                        fake_delete_instance) | ||||||
|  |  | ||||||
|         self.compute.terminate_instance(self.context, instance['uuid']) |         self.compute.terminate_instance(self.context, instance['uuid']) | ||||||
|             raise rpc_common.RemoteError() |         instance = db.instance_get_by_uuid(self.context, instance['uuid']) | ||||||
|  |         self.assertEqual(instance['vm_state'], vm_states.ERROR) | ||||||
|         self.stubs.Set(self.compute, '_allocate_network', |  | ||||||
|                        fake_allocate_network) |  | ||||||
|  |  | ||||||
|         self.assertRaises(rpc_common.RemoteError, |  | ||||||
|                           self.compute.run_instance, |  | ||||||
|                           self.context, |  | ||||||
|                           instance_uuid) |  | ||||||
|  |  | ||||||
|     def test_network_is_deallocated_on_spawn_failure(self): |     def test_network_is_deallocated_on_spawn_failure(self): | ||||||
|         """When a spawn fails the network must be deallocated""" |         """When a spawn fails the network must be deallocated""" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Anthony Young
					Anthony Young