From 8af9e0b98d507ed3bd18f985ef057712aa4cd987 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Fri, 16 Feb 2018 14:51:09 -0800 Subject: [PATCH] Fix default object versioning for Rocky Removing default tagging since we don't carry the mapping information for pike any longer. Change-Id: If0775462f10a60fe1cef84734a07fe30541cf3a1 --- ironic/objects/base.py | 11 ----- ironic/tests/unit/objects/test_objects.py | 59 +---------------------- 2 files changed, 2 insertions(+), 68 deletions(-) diff --git a/ironic/objects/base.py b/ironic/objects/base.py index 9dda3a0c50..94fdac8259 100644 --- a/ironic/objects/base.py +++ b/ironic/objects/base.py @@ -242,17 +242,6 @@ class IronicObject(object_base.VersionedObject): objname = obj.obj_name() db_version = db_object['version'] - if db_version is None: - # NOTE(rloo): This can only happen if the DB is corrupt or this - # is the conductor object. (Because the rest of the objects will - # all have their DB version set properly.) - # TODO(rloo): This entire if clause can be deleted in Rocky - # since the dbsync online migration populates all the conductor - # versions and it must be run to completion before upgrading to - # Rocky. - db_version = versions.RELEASE_MAPPING['pike']['objects'].get( - objname, ['1.0'])[0] - if not versionutils.is_compatible(db_version, obj.__class__.VERSION): raise ovo_exception.IncompatibleObjectVersion( objname=objname, objver=db_version, diff --git a/ironic/tests/unit/objects/test_objects.py b/ironic/tests/unit/objects/test_objects.py index 4da76c7ea0..eb837720f8 100644 --- a/ironic/tests/unit/objects/test_objects.py +++ b/ironic/tests/unit/objects/test_objects.py @@ -506,66 +506,11 @@ class _TestObject(object): def test__from_db_object_old(self): self._test__from_db_object('1.4') - @mock.patch('ironic.common.release_mappings.RELEASE_MAPPING', - autospec=True) - def test__from_db_object_no_version(self, mock_release_mapping): - # DB doesn't have version; get it from mapping - mock_release_mapping.__getitem__.return_value = { - 'objects': { - 'MyObj': ['1.4'], - } - } + def test__from_db_object_map_version_bad(self): obj = MyObj(self.context) dbobj = {'created_at': timeutils.utcnow(), 'updated_at': timeutils.utcnow(), - 'version': None, - 'foo': 123, 'bar': 'test', 'missing': ''} - MyObj._from_db_object(self.context, obj, dbobj) - self.assertEqual(obj.__class__.VERSION, obj.VERSION) - self.assertEqual(123, obj.foo) - self.assertEqual('test', obj.bar) - self.assertEqual('foo', obj.missing) - - @mock.patch('ironic.common.release_mappings.RELEASE_MAPPING', - autospec=True) - def test__from_db_object_no_version_subset_of_fields(self, - mock_release_mapping): - # DB doesn't have version; get it from mapping - mock_release_mapping.__getitem__.return_value = { - 'objects': { - 'MyObj': ['1.5'], - } - } - obj = MyObj(self.context) - dbobj = {'created_at': timeutils.utcnow(), - 'updated_at': timeutils.utcnow(), - 'version': None, - 'foo': 123, 'bar': 'test', 'missing': '', - 'nested_object': 'test'} - # Mock obj_load_attr as this is what is called if an attribute that we - # try to access is not yet set. For all ironic objects it's a noop, - # we've implemented it in MyObj purely for testing - with mock.patch.object(obj, 'obj_load_attr', autospec=True): - MyObj._from_db_object(self.context, obj, dbobj, - fields=['foo', 'bar']) - self.assertEqual(obj.__class__.VERSION, obj.VERSION) - self.assertEqual(123, obj.foo) - self.assertEqual('test', obj.bar) - self.assertRaises(AttributeError, getattr, obj, 'missing') - self.assertEqual('testtest', obj.nested_object) - - @mock.patch('ironic.common.release_mappings.RELEASE_MAPPING', - autospec=True) - def test__from_db_object_map_version_bad(self, mock_release_mapping): - mock_release_mapping.__getitem__.return_value = { - 'objects': { - 'MyObj': ['1.6'], - } - } - obj = MyObj(self.context) - dbobj = {'created_at': timeutils.utcnow(), - 'updated_at': timeutils.utcnow(), - 'version': None, + 'version': '1.99', 'foo': 123, 'bar': 'test', 'missing': ''} self.assertRaises(object_exception.IncompatibleObjectVersion, MyObj._from_db_object, self.context, obj, dbobj)