summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Lamar <brian.lamar@rackspace.com>2012-06-29 13:28:04 -0400
committerBrian Lamar <brian.lamar@rackspace.com>2012-06-29 16:52:55 -0400
commitfd7a111cbfe77decfa5adda35793aae6ac7db6ba (patch)
tree42dd94669d6e6a932233da0baf3594c33bd41a57
parent1a4cb537e402a9cfb8f2a007c4033b2da90828f6 (diff)
downloadnova-fd7a111cbfe77decfa5adda35793aae6ac7db6ba.tar.gz
nova-fd7a111cbfe77decfa5adda35793aae6ac7db6ba.tar.xz
nova-fd7a111cbfe77decfa5adda35793aae6ac7db6ba.zip
Ability to read deleted system metadata records.
Update _instance_system_metadata_get_query to use read_deleted from the passed in context instead of just hard-coding "no". Also, use this to ensure system metadata is always collected during delete, even if the instance was deleted elsewhere. Fixes bug 1019357 Change-Id: I9285f110801435344fcaa76ba21fb88c23aac2fa
-rw-r--r--nova/compute/manager.py8
-rw-r--r--nova/db/sqlalchemy/api.py4
2 files changed, 5 insertions, 7 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index deca04177..3cdf35266 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -761,12 +761,10 @@ class ComputeManager(manager.SchedulerDependentManager):
vm_state=vm_states.DELETED,
task_state=None,
terminated_at=timeutils.utcnow())
- # Pull the system_metadata before we delete the instance, so we
- # can pass it to delete.end notification, as it will not be able
- # to look it up anymore, if it needs it.
- system_meta = self.db.instance_system_metadata_get(context,
- instance_uuid)
self.db.instance_destroy(context, instance_uuid)
+ with utils.temporary_mutation(context, read_deleted="yes"):
+ system_meta = self.db.instance_system_metadata_get(context,
+ instance_uuid)
self._notify_about_instance_usage(context, instance, "delete.end",
system_metadata=system_meta)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index bc0ba5307..50dd5b824 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -4240,8 +4240,8 @@ def instance_metadata_update(context, instance_uuid, metadata, delete):
# System-owned metadata
def _instance_system_metadata_get_query(context, instance_uuid, session=None):
- return model_query(context, models.InstanceSystemMetadata, session=session,
- read_deleted="no").\
+ return model_query(context, models.InstanceSystemMetadata,
+ session=session).\
filter_by(instance_uuid=instance_uuid)