summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEoghan Glynn <eglynn@redhat.com>2012-10-20 15:39:32 +0100
committerEoghan Glynn <eglynn@redhat.com>2012-10-20 15:47:22 +0100
commit30b997d31953d35213ad39ddb3804d791efe5a22 (patch)
tree22d5b0f4acf7801bde33f3be65633a379691d716
parent2cb47fbabf09ced76178e8453d508c66f86a7a3a (diff)
Avoid leaking BDMs for deleted instances.
Fixes bug 1069099 Previously when an instance was deleted, the corresponding entries in the block device mappings table were not also marked as deleted. Change-Id: I0184eb2f02a9ed363019c585efffdfdb95f0bb43
-rw-r--r--nova/compute/manager.py5
-rw-r--r--nova/tests/compute/test_compute.py3
2 files changed, 8 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 6088cbf30..a1aa07b54 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -916,6 +916,11 @@ class ComputeManager(manager.SchedulerDependentManager):
self.db.instance_destroy(context, instance_uuid)
system_meta = self.db.instance_system_metadata_get(context,
instance_uuid)
+
+ # ensure block device mappings are not leaked
+ for bdm in bdms:
+ self.db.block_device_mapping_destroy(context, bdm['id'])
+
self._notify_about_instance_usage(context, instance, "delete.end",
system_metadata=system_meta)
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 6fc317775..3cfb4a46d 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -627,6 +627,9 @@ class ComputeTestCase(BaseTestCase):
instances = db.instance_get_all(context.get_admin_context())
LOG.info(_("After terminating instances: %s"), instances)
self.assertEqual(len(instances), 0)
+ bdms = db.block_device_mapping_get_all_by_instance(self.context,
+ instance['uuid'])
+ self.assertEqual(len(bdms), 0)
def test_terminate_no_network(self):
# This is as reported in LP bug 1008875