From 9075069098e32b47bd5011e2653a23b61c18d4a3 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 21 Mar 2013 15:08:18 -0400 Subject: Initialize compute manager before loading driver. The compute virt API uses the conductor API instance on the compute manager. Make sure the compute manager has been fully initialized before loading the driver and passing it the virtapi instance. This prevents the possibility of the driver calling back into the compute manager and using something not initialized yet, such as the conductor API in the case of this bug. This patch also moves initialization of a member variable up above super(), where the rest of the initialization is. There doesn't appear to be a reason for needing to have it at the end. Fix bug 1156490. Change-Id: I19684f24d590201d135336107425c2be2f74c83e --- nova/compute/manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 604362783..fda7f490a 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -329,7 +329,6 @@ class ComputeManager(manager.SchedulerDependentManager): def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" self.virtapi = ComputeVirtAPI(self) - self.driver = driver.load_compute_driver(self.virtapi, compute_driver) self.network_api = network.API() self.volume_api = volume.API() self._last_host_check = 0 @@ -343,11 +342,15 @@ class ComputeManager(manager.SchedulerDependentManager): openstack_driver.is_quantum_security_groups()) self.consoleauth_rpcapi = consoleauth.rpcapi.ConsoleAuthAPI() self.cells_rpcapi = cells_rpcapi.CellsAPI() + self._resource_tracker_dict = {} super(ComputeManager, self).__init__(service_name="compute", *args, **kwargs) - self._resource_tracker_dict = {} + # NOTE(russellb) Load the driver last. It may call back into the + # compute manager via the virtapi, so we want it to be fully + # initialized before that happens. + self.driver = driver.load_compute_driver(self.virtapi, compute_driver) def _get_resource_tracker(self, nodename): rt = self._resource_tracker_dict.get(nodename) -- cgit