Skip to content

Instantly share code, notes, and snippets.

@mriedem
Created November 20, 2015 18:22
Show Gist options
  • Save mriedem/fdf0edfa19632f151f6d to your computer and use it in GitHub Desktop.
Save mriedem/fdf0edfa19632f151f6d to your computer and use it in GitHub Desktop.
mriedem@ubuntu:~/git/nova$ git diff
diff --git a/nova/objects/instance.py b/nova/objects/instance.py
index b010b7f..1b54446 100644
--- a/nova/objects/instance.py
+++ b/nova/objects/instance.py
@@ -739,9 +739,12 @@ class Instance(base.NovaPersistentObject, base.NovaObject,
self._context, self.uuid)
def _load_flavor(self):
- instance = self.__class__.get_by_uuid(
- self._context, uuid=self.uuid,
- expected_attrs=['flavor', 'system_metadata'])
+ # NOTE(mriedem): The API allows you to read deleted instances so we
+ # need to temporarily mutate the context to read the deleted instance.
+ with utils.temporary_mutation(self._context, read_deleted='yes'):
+ instance = self.__class__.get_by_uuid(
+ self._context, uuid=self.uuid,
+ expected_attrs=['flavor', 'system_metadata'])
# NOTE(danms): Orphan the instance to make sure we don't lazy-load
# anything below
mriedem@ubuntu:~/git/nova$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment