Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use manifest to backport OVOs during upgrades
To make objects that have other objects as fields compatible to an earlier version, oslo versioned objects uses either a manifest passed to obj_to_primitive or the object's obj_relationships mapping. Which means that if we don't have any of those mechanisms in place our rolling upgrades mechanism will fail whenever we try to backport a Versioned Object that has set an ObjectField field because Oslo Versioned Object will not know how to backport that related object. This patch introduces the usage of manifests on backports when we are doing rolling upgrades. For the manifest, we use the data in our Objects History. Which means that as long as we keep history in OBJ_VERSIONS right we will not have to create and worry about keeping lists' child_versions field or our versioned object's obj_relationships for fields with types ListOfObjectsField and ObjectField. We also don't have to worry about cascade version bumping, as in changing the List OVO version whenever the OVO it contains gets bumped, or bumping our OVO whenever one of the related OVO fields is bumped. Closes-Bug: #1571566 Change-Id: Ibc1a1257830c925c10696c0b5aedd5f471c538d0 (cherry picked from commit f0d34b7)
- Loading branch information
Showing
17 changed files
with
224 additions
and
80 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright (c) 2016 Red Hat Inc. | ||
# Copyright (c) 2016 Intel Corp. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from oslo_utils import versionutils | ||
|
||
from cinder import objects | ||
|
||
|
||
@objects.base.CinderObjectRegistry.register_if(False) | ||
class ChildObject(objects.base.CinderObject): | ||
VERSION = '1.2' | ||
|
||
fields = { | ||
'scheduled_at': objects.base.fields.DateTimeField(nullable=True), | ||
'uuid': objects.base.fields.UUIDField(), | ||
'text': objects.base.fields.StringField(nullable=True), | ||
'integer': objects.base.fields.IntegerField(nullable=True), | ||
} | ||
|
||
def obj_make_compatible(self, primitive, target_version): | ||
super(ChildObject, self).obj_make_compatible(primitive, | ||
target_version) | ||
target_version = versionutils.convert_version_to_tuple(target_version) | ||
if target_version < (1, 1): | ||
primitive.pop('text', None) | ||
if target_version < (1, 2): | ||
primitive.pop('integer', None) | ||
|
||
|
||
@objects.base.CinderObjectRegistry.register_if(False) | ||
class ParentObject(objects.base.CinderObject): | ||
VERSION = '1.1' | ||
|
||
fields = { | ||
'uuid': objects.base.fields.UUIDField(), | ||
'child': objects.base.fields.ObjectField('ChildObject', nullable=True), | ||
'scheduled_at': objects.base.fields.DateTimeField(nullable=True), | ||
} | ||
|
||
def obj_make_compatible(self, primitive, target_version): | ||
super(ParentObject, self).obj_make_compatible(primitive, | ||
target_version) | ||
target_version = versionutils.convert_version_to_tuple(target_version) | ||
if target_version < (1, 1): | ||
primitive.pop('scheduled_at', None) | ||
|
||
|
||
@objects.base.CinderObjectRegistry.register_if(False) | ||
class ParentObjectList(objects.base.CinderObject, objects.base.ObjectListBase): | ||
VERSION = ParentObject.VERSION | ||
|
||
fields = { | ||
'objects': objects.base.fields.ListOfObjectsField('ParentObject'), | ||
} | ||
|
||
|
||
class MyHistory(objects.base.CinderObjectVersionsHistory): | ||
linked_objects = {'ParentObject': 'ParentObjectList'} | ||
|
||
def __init__(self): | ||
self.versions = ['1.0'] | ||
self['1.0'] = {'ChildObject': '1.0'} | ||
self.add('1.1', {'ChildObject': '1.1'}) | ||
self.add('1.2', {'ParentObject': '1.0'}) | ||
self.add('1.3', {'ParentObjectList': '1.0'}) | ||
self.add('1.4', {'ParentObject': '1.1'}) | ||
self.add('1.5', {'ParentObjectList': '1.1'}) | ||
self.add('1.6', {'ChildObject': '1.2'}) |
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
Oops, something went wrong.