From 1c8ad4553b4b8d404f941c5297e3f6e42c9f7e6a Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Sun, 12 Feb 2012 13:34:14 -0500 Subject: Completes fix for LP #928910 - libvirt performance This patch adds the remainder of the recommended fixes from the original bug report: * Modifies methods in the compute manager that relied on the DB power state to be in sync with the virt driver to instead just query the power state of the instance from the virt driver. This enables us to set the periodic tick to 10 for the problematic compute.manager.Manager._sync_power_states() method. * Modifies the _sync_power_states method in the following ways: ** Replace the call to driver.list_instances_detail() to a new, driver-overrideable get_num_instances() call ** For each instance known by the database, call driver.get_info() separately inside the loop instead of calling the expensive list_instances_detail() method that can take a very long time to complete on hosts with lots of instances ** Call greenthread.sleep(0) before each call to update the database power state, enabling other periodic tasks to do work Once again, I left an inefficient default implementation of the new driver.get_num_instances() method in the base driver class. I need help from folks who understand the Xen/VMWare drivers to do an override for get_num_instances() in those drivers that calls the underlying XenAPI or VMWare API. Change-Id: I88002689cdda32124423da320f8c542e286be51b --- nova/tests/test_compute.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'nova/tests') diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 4908f66db..9b7fa1ca6 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -552,6 +552,17 @@ class ComputeTestCase(BaseTestCase): instance = db.instance_get_by_uuid(self.context, instance['uuid']) self.assertEqual(instance['power_state'], power_state.NOSTATE) + + def fake_driver_get_info(self2, _instance): + return {'state': power_state.NOSTATE, + 'max_mem': 0, + 'mem': 0, + 'num_cpu': 2, + 'cpu_time': 0} + + self.stubs.Set(nova.virt.fake.FakeConnection, 'get_info', + fake_driver_get_info) + self.assertRaises(exception.Error, self.compute.set_admin_password, self.context, @@ -1453,7 +1464,7 @@ class ComputeTestCase(BaseTestCase): # Force the compute manager to do its periodic poll ctxt = context.get_admin_context() - self.compute.periodic_tasks(ctxt, raise_on_error=True) + self.compute._sync_power_states(context.get_admin_context()) instances = db.instance_get_all(context.get_admin_context()) LOG.info(_("After force-killing instances: %s"), instances) -- cgit