summaryrefslogtreecommitdiff
path: root/nova/objects
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2018-06-13 11:14:37 -0700
committerMatt Riedemann <mriedem.os@gmail.com>2018-11-27 12:42:48 -0500
commit604819b29c0bd43969747d32f6e3d818b3cbece7 (patch)
treeebe8256c60021b091568c343d27881d23ff34d1f /nova/objects
parent92dbeae1d43bee0f44953e170ae2c9ee181793ef (diff)
downloadnova-604819b29c0bd43969747d32f6e3d818b3cbece7.tar.gz
Always read-deleted=yes on lazy-load
For some reason we were only reading deleted instances when loading generic fields and not things like flavor. That weird behavior isn't very helpful, so this makes us always read deleted for that case. Some of the fields, like tags, will short-circuit that and just immediately lazy-load an empty set. But for anything else, we should allow reading that data if it's still there. With this change, we are able to remove a specific read_deleted='yes' usage from ComputeManager._destroy_evacuated_instances() which is handled with the generic solution. TestEvacuateDeleteServerRestartOriginalCompute asserts that the evacuate scenario is still fixed. Related-Bug: #1794996 Related-Bug: #1745977 Change-Id: I8ec3a3a697e55941ee447d0b52d29785717e4bf0
Diffstat (limited to 'nova/objects')
-rw-r--r--nova/objects/instance.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/nova/objects/instance.py b/nova/objects/instance.py
index 010efc10a1..15c07663cc 100644
--- a/nova/objects/instance.py
+++ b/nova/objects/instance.py
@@ -899,10 +899,9 @@ class Instance(base.NovaPersistentObject, base.NovaObject,
self.obj_reset_changes()
def _load_generic(self, attrname):
- with utils.temporary_mutation(self._context, read_deleted='yes'):
- instance = self.__class__.get_by_uuid(self._context,
- uuid=self.uuid,
- expected_attrs=[attrname])
+ instance = self.__class__.get_by_uuid(self._context,
+ uuid=self.uuid,
+ expected_attrs=[attrname])
if attrname not in instance:
# NOTE(danms): Never allow us to recursively-load
@@ -1111,6 +1110,24 @@ class Instance(base.NovaPersistentObject, base.NovaObject,
'uuid': self.uuid,
})
+ with utils.temporary_mutation(self._context, read_deleted='yes'):
+ self._obj_load_attr(attrname)
+
+ def _obj_load_attr(self, attrname):
+ """Internal method for loading attributes from instances.
+
+ NOTE: Do not use this directly.
+
+ This method contains the implementation of lazy-loading attributes
+ from Instance object, minus some massaging of the context and
+ error-checking. This should always be called with the object-local
+ context set for reading deleted instances and with uuid set. All
+ of the code below depends on those two things. Thus, this should
+ only be called from obj_load_attr() itself.
+
+ :param attrname: The name of the attribute to be loaded
+ """
+
# NOTE(danms): We handle some fields differently here so that we
# can be more efficient
if attrname == 'fault':