Skip to content

Commit

Permalink
Avoid leaking BDMs for deleted instances.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Eoghan Glynn committed Oct 22, 2012
1 parent d1e462d commit f67a5f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nova/compute/manager.py
Expand Up @@ -912,6 +912,11 @@ def _delete_instance(self, context, instance):
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 self._get_instance_volume_bdms(context, instance_uuid):
self.db.block_device_mapping_destroy(context, bdm['id'])

self._notify_about_instance_usage(context, instance, "delete.end",
system_metadata=system_meta)

Expand Down
3 changes: 3 additions & 0 deletions nova/tests/compute/test_compute.py
Expand Up @@ -617,6 +617,9 @@ def fake_volume_get(self, context, volume_id):
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
Expand Down

0 comments on commit f67a5f9

Please sign in to comment.