Created
July 3, 2018 16:36
-
-
Save mriedem/3f1560a7e9697ade633ab11b6aab8c62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/nova/objects/instance.py b/nova/objects/instance.py | |
index 27fd416..0df32ab 100644 | |
--- a/nova/objects/instance.py | |
+++ b/nova/objects/instance.py | |
@@ -324,17 +324,32 @@ class Instance(base.NovaPersistentObject, base.NovaObject, | |
def _flavor_from_db(self, db_flavor): | |
"""Load instance flavor information from instance_extra.""" | |
+ # Before we stored flavors in instance_extra, certain fields, defined | |
+ # in nova.compute.flavors.system_metadata_flavor_props, were stored | |
+ # in the instance.system_metadata for the embedded instance.flavor. | |
+ # The "disabled" field wasn't one of those keys, however, so really | |
+ # old instances that had their embedded flavor converted to the | |
+ # serialized instance_extra form won't have the disabled attribute | |
+ # set and we need to heal those here so callers don't explode trying | |
+ # to load instance.flavor.disabled. | |
+ def _heal_disabled(flavor): | |
+ if 'disabled' not in flavor: | |
+ flavor.disabled = False | |
+ | |
flavor_info = jsonutils.loads(db_flavor) | |
self.flavor = objects.Flavor.obj_from_primitive(flavor_info['cur']) | |
+ _heal_disabled(self.flavor) | |
if flavor_info['old']: | |
self.old_flavor = objects.Flavor.obj_from_primitive( | |
flavor_info['old']) | |
+ _heal_disabled(self.old_flavor) | |
else: | |
self.old_flavor = None | |
if flavor_info['new']: | |
self.new_flavor = objects.Flavor.obj_from_primitive( | |
flavor_info['new']) | |
+ _heal_disabled(self.new_flavor) | |
else: | |
self.new_flavor = None | |
self.obj_reset_changes(['flavor', 'old_flavor', 'new_flavor']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment