From fa16d173938b30af4e1cc6b312a75b12aff6c424 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 17 Aug 2012 15:21:36 -0400 Subject: Fix get_vnc_console race. There exists a window between a server create is done and when the host is assigned by the scheduler that a request to get the vnc console will result in a 500 error. This patch adds a check in the compute API to ensure that the instance has a host assigned before try to execute a rpc on the compute node. If not, it raises InstanceNotReady (which translates to a 409 in the OS API). Fix bug 1037809. Change-Id: I3f5af90d57ae84f98f787e14ccb66f1841ac0c6d --- nova/tests/compute/test_compute.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 8a46d51ec..64d7fb960 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3896,6 +3896,15 @@ class ComputeAPITestCase(BaseTestCase): fake_instance, fake_console_type) self.assertEqual(console, {'url': 'fake_console_url'}) + def test_get_vnc_console_no_host(self): + instance = self._create_fake_instance(params={'host': ''}) + + self.assertRaises(exception.InstanceNotReady, + self.compute_api.get_vnc_console, + self.context, instance, 'novnc') + + db.instance_destroy(self.context, instance['uuid']) + def test_console_output(self): fake_instance = {'uuid': 'fake_uuid', 'host': 'fake_compute_host'} -- cgit