diff options
author | David McNally <dave.mcnally@hp.com> | 2013-06-14 14:03:56 +0100 |
---|---|---|
committer | David McNally <dave.mcnally@hp.com> | 2013-06-26 14:38:24 +0100 |
commit | 3d260fc94201078f27d892049b2f8e9269e837f8 (patch) | |
tree | 6871a5fc41ebdffea623a1ad8d77add635c52908 | |
parent | 7696c3c11f0de855cbc53cc04ee7d2be07ae3b9c (diff) | |
download | nova-3d260fc94201078f27d892049b2f8e9269e837f8.tar.gz nova-3d260fc94201078f27d892049b2f8e9269e837f8.tar.xz nova-3d260fc94201078f27d892049b2f8e9269e837f8.zip |
Fix for failure of periodic instance cleanup
The periodic task to identify and (optionally) delete instances which
are running on the host but marked as deleted in the nova database currently fails
if the option to delete is selected.
This failure is because the instance data returned from the query in
nova.compute.manager:_get_instances_on_driver does not include the system metadata
expected by nova.compute.flavors:extract_instance_type.
This change alters _get_instances_on_driver so the calling function can specify
columns_to_join which is used in the call to instance_get_all_by_filters (leaving
this set to None, rather than [] as it is currently, joins the default columns which
includes the required system metadata).
bug: 1190206
Change-Id: I44aecebdb4d0e20e52fdd59b46a022483cdd19d5
-rwxr-xr-x | nova/compute/manager.py | 7 | ||||
-rw-r--r-- | nova/tests/compute/test_compute.py | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index a242a121d..741f3a545 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -409,7 +409,8 @@ class ComputeManager(manager.SchedulerDependentManager): 'trying to set it to ERROR'), instance_uuid=instance_uuid) - def _get_instances_on_driver(self, context, filters=None): + def _get_instances_on_driver(self, context, filters=None, + columns_to_join=None): """Return a list of instance records for the instances found on the hypervisor which satisfy the specified filters. If filters=None return a list of instance records for all the instances found on the @@ -421,7 +422,7 @@ class ComputeManager(manager.SchedulerDependentManager): driver_uuids = self.driver.list_instance_uuids() filters['uuid'] = driver_uuids local_instances = self.conductor_api.instance_get_all_by_filters( - context, filters, columns_to_join=[]) + context, filters, columns_to_join=columns_to_join) return local_instances except NotImplementedError: pass @@ -430,7 +431,7 @@ class ComputeManager(manager.SchedulerDependentManager): # to brute force. driver_instances = self.driver.list_instances() instances = self.conductor_api.instance_get_all_by_filters( - context, filters, columns_to_join=[]) + context, filters, columns_to_join=columns_to_join) name_map = dict((instance['name'], instance) for instance in instances) local_instances = [] for driver_instance in driver_instances: diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index e2783641c..2a6651cd1 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -5119,7 +5119,8 @@ class ComputeTestCase(BaseTestCase): self.mox.ReplayAll() - result = self.compute._get_instances_on_driver(fake_context) + result = self.compute._get_instances_on_driver(fake_context, + columns_to_join=[]) self.assertEqual(driver_instances, result) def test_get_instances_on_driver_fallback(self): @@ -5150,7 +5151,7 @@ class ComputeTestCase(BaseTestCase): [inst['name'] for inst in driver_instances]) self.compute.conductor_api.instance_get_all_by_filters( fake_context, filters, - columns_to_join=[]).AndReturn(all_instances) + columns_to_join=None).AndReturn(all_instances) self.mox.ReplayAll() |