From f9a89b7065ff4a15bf7ce14a983e8934cd4710f4 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Mon, 18 Mar 2013 20:26:02 +0000 Subject: Fix XenAPI performance issue This patch implements 'list_instance_uuids' in the xenapi virt driver so that compute manager's '_get_instances_on_driver' can operate more efficiently. Fixes bug 1097980 The cleanup_running_deleted_instances periodic task uses the above call while context has been modified to be read_deleted='yes'. Without list_instance_uuids being implemented in xenapi, there's a fallback to querying all instances on the host. Because of read_deleted='yes', this queries all instances that have ever lived on the host. In a very busy environment where instances are repeatedly built and destroyed, one can end up with thousands of deleted instances. Now that we are storing instance_type data in system_metadata and system_metadata is joined with every instance_get, this results in 10x the number of rows being returned with sqlalchemy... the fallback doesn't perform well enough. Change-Id: I4bbfd69c9769807cec813af757665f03d9643460 --- nova/tests/test_xenapi.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 6714161f1..330a229ab 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -374,6 +374,19 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): instances = self.conn.list_instances() self.assertEquals(instances, []) + def test_list_instance_uuids_0(self): + instance_uuids = self.conn.list_instance_uuids() + self.assertEquals(instance_uuids, []) + + def test_list_instance_uuids(self): + uuids = [] + for x in xrange(1, 4): + instance = self._create_instance(x) + uuids.append(instance['uuid']) + instance_uuids = self.conn.list_instance_uuids() + self.assertEqual(len(uuids), len(instance_uuids)) + self.assertEqual(set(uuids), set(instance_uuids)) + def test_get_rrd_server(self): self.flags(xenapi_connection_url='myscheme://myaddress/') server_info = vm_utils._get_rrd_server() -- cgit