SlideShare a Scribd company logo
oslo.versionedobjects:
Deep Dive
Dan Smith
What is it?
● Object model to solve problems we had in
nova
● Each RPC-visible change is versioned
● Remotable, serializable
● Backportable
What is it? (versioning)
● Attempt to get away from dicts (of madness)
● Fields are defined and typed, with
serialization routines
● Defined at the edges, no embedding code or
class names in the serialized form
● Controlled evolution of object/RPC schema
independent of DB schema over time
What is it? (remotable)
● You implement Indirection API (nova-
conductor implements for nova)
● @remotable methods get called via
indirection
● Self-serializing
obj.do_thing()
def do_thing()
def do_thing()
DB
Indirection
Service
@remotable
When indirection
is active
● Remotable methods wrapped with
decorator
● Calls may avoid the local
implementation and make the call run
through the indirection service
● Same implementation both places!
● Copy of the object (including version)
is sent
● Object (may be) modified on remote,
changes copied back to the caller
Remotable Methods
What is it not?
● Amazingly novel
● ...going to solve world hunger
● ...going to solve your problems (alone)
● A lemming
from oslo.versionedobjects import base
from oslo.versionedobjects import base
class MyObject(base.VersionedObject):
# Version 1.0: Initial
# Version 1.1: Added ‘name’ field
VERSION = ‘1.1’
fields = {
‘id’: fields.IntegerField(nullable=False),
‘name’: fields.StringField(nullable=True),
‘metadata’: fields.DictOfStringsField(nullable=True),
}
@base.remotable_classmethod
def get_by_id(cls, context, id):
db_thingy = db.get_thingy(context, id)
obj = cls(context=context,
id=db_thingy[‘id’],
name=db_thingy.get(‘thingy_name’),
metadata=db.get_metadata_for(context, id))
obj.obj_reset_changes()
return obj
Careful, humans will put non-
versioned stuff in here and cause
problems (as humans do)!
class MyObject(base.VersionedObject):
# … continued
@base.remotable
def save(self):
changes = self.obj_what_changed()
db_updates = {}
if ‘id’ in changes:
raise Exception(‘Can’t change the id!’)
if ‘name’ in changes:
db_updates[‘thingy_name’] = self.name
with db.transaction():
if ‘metadata’ in changes:
db.update_metadata_for(self.context, self.id,
self.metadata)
if db_updates:
db.update_thingy(self.context, self.id, db_updates)
self.obj_reset_changes()
Lazy-Loading
● Attributes can be set or unset, independent
of nullability (i.e. “can be None”)
● Loadable attributes handled by a method
● In practice, only some (heavy) attributes are
loadable
class MyObject(base.VersionedObject):
# … continued
# Not remotable!
def obj_load_attr(self, attrname):
if attrname == ‘metadata’:
obj = self.get_by_id(self.context, self.id)
self.metadata = obj.metadata
self.obj_reset_changes()
else:
# Fail as not-lazy-loadable
super(MyObject, self).obj_load_attr(attrname)
Serialization
● Convert object to/from serialized form
● Field implementations are responsible for
serializing their contents (not your object)
● Serializer object actually produces the result
● Nova uses JSON, but you can do whatever
● Object mentions no classnames or code,
relies on the model to deserialize
Serialization (continued)
● Most services will need to have a request
context for all operations
● Object stores this for ease and security
● Each RPC trip re-attaches the context of the
RPC call, so context is not serialized!
● Can be anything or ignored if you don’t need
it
obj = MyObj(id=123, name=’foo’, metadata={‘speed’: ‘88mph’})
prim = obj.obj_to_primitive()
string = json.dumps(prim)
reprim = json.loads(string)
reobj = VersionedObject.obj_from_primitive(reprim, context)
class MyRPCClientAPI(object):
def __init__(self):
# ...
serializer = base.VersionedObjectSerializer()
self.client = self.get_client(target, version_cap, serializer)
class MyRPCServerAPI(service.Service):
def start():
# ...
serializer = base.VersionedObjectSerializer()
self.rpcserver = rpc.get_server(target, endpoints, serializer)
self.rpcserver.start()
Versioning
● Requires diligence (with some tools to help
catch offenders)
● Backwards-compatible changes
● Recipients should honor old versions
● Senders can pre-backport to older versions
● Nova does this automatically, but simply
pinning versions is an easy way
class MyObject(base.VersionedObject):
# … continued
def obj_make_compatible(self, primitive, version):
if version == ‘1.0’:
del primitive[‘name’]
obj = MyObject(id=123, name=’foo’, metadata={‘speed’: ‘88mph’})
prim = obj.obj_to_primitive(target_version=’1.0’)
# Now prim won’t have the ‘name’ field
oldobj = VersionedObject.obj_from_primitive(prim, context)
self.assertFalse(oldobj.obj_attr_is_set(‘name’))
Why do this?
● Get a better handle on what you’re sending
over RPC and what happens if you change
● Decouples the database from services,
allowing DB schema upgrades independent
of object schemas
● Easy serialization without sacrificing rich
typing and bundled methods
Why not do this?
● Because it will magically solve upgrade
problems (it won’t)
● Because you have a better way
● Because it doesn’t fit your model or process
● Because the name is too boring

More Related Content

What's hot

Introduction of Object Oriented JavaScript
Introduction of Object Oriented JavaScriptIntroduction of Object Oriented JavaScript
Introduction of Object Oriented JavaScript
NexThoughts Technologies
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understanding
mametter
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
mametter
 
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App development
Jayaprakash R
 
Invitation to the dark side of Ruby
Invitation to the dark side of RubyInvitation to the dark side of Ruby
Invitation to the dark side of Ruby
SATOSHI TAGOMORI
 
Type Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesType Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signatures
mametter
 
Declarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetationDeclarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetation
Om Shankar
 
Maccro Strikes Back
Maccro Strikes BackMaccro Strikes Back
Maccro Strikes Back
SATOSHI TAGOMORI
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in Pharo
Marcus Denker
 
Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
Hùng Nguyễn Huy
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
JAVA CLASS1
JAVA CLASS1JAVA CLASS1
JAVA CLASS1
Prudhvi Akella
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin Coroutines
Roman Elizarov
 
Let's JavaScript
Let's JavaScriptLet's JavaScript
Let's JavaScript
Paweł Dorofiejczyk
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
mperham
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
Garrett Welson
 
Guild Prototype
Guild PrototypeGuild Prototype
Guild Prototype
Koichi Sasada
 
JS Event Loop
JS Event LoopJS Event Loop
JS Event Loop
Saai Vignesh P
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
Ivano Malavolta
 

What's hot (20)

Introduction of Object Oriented JavaScript
Introduction of Object Oriented JavaScriptIntroduction of Object Oriented JavaScript
Introduction of Object Oriented JavaScript
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understanding
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
 
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App development
 
Invitation to the dark side of Ruby
Invitation to the dark side of RubyInvitation to the dark side of Ruby
Invitation to the dark side of Ruby
 
Type Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesType Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signatures
 
Declarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetationDeclarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetation
 
Maccro Strikes Back
Maccro Strikes BackMaccro Strikes Back
Maccro Strikes Back
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in Pharo
 
Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
 
Callback Function
Callback FunctionCallback Function
Callback Function
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
JAVA CLASS1
JAVA CLASS1JAVA CLASS1
JAVA CLASS1
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin Coroutines
 
Let's JavaScript
Let's JavaScriptLet's JavaScript
Let's JavaScript
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Guild Prototype
Guild PrototypeGuild Prototype
Guild Prototype
 
JS Event Loop
JS Event LoopJS Event Loop
JS Event Loop
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
 

Similar to Oslo.versioned objects - Deep Dive

Node js
Node jsNode js
Node jshazzaz
 
Dragoncraft Architectural Overview
Dragoncraft Architectural OverviewDragoncraft Architectural Overview
Dragoncraft Architectural Overview
jessesanford
 
Learn To Code: Introduction to java
Learn To Code: Introduction to javaLearn To Code: Introduction to java
Learn To Code: Introduction to java
SadhanaParameswaran
 
Lecture4 corba
Lecture4   corbaLecture4   corba
Lecture4 corba
poovi117
 
Level DB - Quick Cheat Sheet
Level DB - Quick Cheat SheetLevel DB - Quick Cheat Sheet
Level DB - Quick Cheat Sheet
Aniruddha Chakrabarti
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
Oswald Campesato
 
PofEAA and SQLAlchemy
PofEAA and SQLAlchemyPofEAA and SQLAlchemy
PofEAA and SQLAlchemyInada Naoki
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
cacois
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time Checks
Stoyan Nikolov
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Sam Muhanguzi
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
rsebbe
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
Quinton Sheppard
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)Piyush Katariya
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
Ran Mizrahi
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
JAX London
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
Eberhard Wolff
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
e-Legion
 
"Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin "Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin
Vasil Remeniuk
 
SyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserializationSyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserialization
David Jorm
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactions
tepsum
 

Similar to Oslo.versioned objects - Deep Dive (20)

Node js
Node jsNode js
Node js
 
Dragoncraft Architectural Overview
Dragoncraft Architectural OverviewDragoncraft Architectural Overview
Dragoncraft Architectural Overview
 
Learn To Code: Introduction to java
Learn To Code: Introduction to javaLearn To Code: Introduction to java
Learn To Code: Introduction to java
 
Lecture4 corba
Lecture4   corbaLecture4   corba
Lecture4 corba
 
Level DB - Quick Cheat Sheet
Level DB - Quick Cheat SheetLevel DB - Quick Cheat Sheet
Level DB - Quick Cheat Sheet
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
PofEAA and SQLAlchemy
PofEAA and SQLAlchemyPofEAA and SQLAlchemy
PofEAA and SQLAlchemy
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time Checks
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
 
"Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin "Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin
 
SyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserializationSyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserialization
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactions
 

Recently uploaded

Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 

Recently uploaded (20)

Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 

Oslo.versioned objects - Deep Dive

  • 2. What is it? ● Object model to solve problems we had in nova ● Each RPC-visible change is versioned ● Remotable, serializable ● Backportable
  • 3. What is it? (versioning) ● Attempt to get away from dicts (of madness) ● Fields are defined and typed, with serialization routines ● Defined at the edges, no embedding code or class names in the serialized form ● Controlled evolution of object/RPC schema independent of DB schema over time
  • 4. What is it? (remotable) ● You implement Indirection API (nova- conductor implements for nova) ● @remotable methods get called via indirection ● Self-serializing
  • 5. obj.do_thing() def do_thing() def do_thing() DB Indirection Service @remotable When indirection is active ● Remotable methods wrapped with decorator ● Calls may avoid the local implementation and make the call run through the indirection service ● Same implementation both places! ● Copy of the object (including version) is sent ● Object (may be) modified on remote, changes copied back to the caller Remotable Methods
  • 6. What is it not? ● Amazingly novel ● ...going to solve world hunger ● ...going to solve your problems (alone) ● A lemming
  • 7. from oslo.versionedobjects import base from oslo.versionedobjects import base class MyObject(base.VersionedObject): # Version 1.0: Initial # Version 1.1: Added ‘name’ field VERSION = ‘1.1’ fields = { ‘id’: fields.IntegerField(nullable=False), ‘name’: fields.StringField(nullable=True), ‘metadata’: fields.DictOfStringsField(nullable=True), } @base.remotable_classmethod def get_by_id(cls, context, id): db_thingy = db.get_thingy(context, id) obj = cls(context=context, id=db_thingy[‘id’], name=db_thingy.get(‘thingy_name’), metadata=db.get_metadata_for(context, id)) obj.obj_reset_changes() return obj Careful, humans will put non- versioned stuff in here and cause problems (as humans do)!
  • 8. class MyObject(base.VersionedObject): # … continued @base.remotable def save(self): changes = self.obj_what_changed() db_updates = {} if ‘id’ in changes: raise Exception(‘Can’t change the id!’) if ‘name’ in changes: db_updates[‘thingy_name’] = self.name with db.transaction(): if ‘metadata’ in changes: db.update_metadata_for(self.context, self.id, self.metadata) if db_updates: db.update_thingy(self.context, self.id, db_updates) self.obj_reset_changes()
  • 9. Lazy-Loading ● Attributes can be set or unset, independent of nullability (i.e. “can be None”) ● Loadable attributes handled by a method ● In practice, only some (heavy) attributes are loadable
  • 10. class MyObject(base.VersionedObject): # … continued # Not remotable! def obj_load_attr(self, attrname): if attrname == ‘metadata’: obj = self.get_by_id(self.context, self.id) self.metadata = obj.metadata self.obj_reset_changes() else: # Fail as not-lazy-loadable super(MyObject, self).obj_load_attr(attrname)
  • 11. Serialization ● Convert object to/from serialized form ● Field implementations are responsible for serializing their contents (not your object) ● Serializer object actually produces the result ● Nova uses JSON, but you can do whatever ● Object mentions no classnames or code, relies on the model to deserialize
  • 12. Serialization (continued) ● Most services will need to have a request context for all operations ● Object stores this for ease and security ● Each RPC trip re-attaches the context of the RPC call, so context is not serialized! ● Can be anything or ignored if you don’t need it
  • 13. obj = MyObj(id=123, name=’foo’, metadata={‘speed’: ‘88mph’}) prim = obj.obj_to_primitive() string = json.dumps(prim) reprim = json.loads(string) reobj = VersionedObject.obj_from_primitive(reprim, context)
  • 14. class MyRPCClientAPI(object): def __init__(self): # ... serializer = base.VersionedObjectSerializer() self.client = self.get_client(target, version_cap, serializer) class MyRPCServerAPI(service.Service): def start(): # ... serializer = base.VersionedObjectSerializer() self.rpcserver = rpc.get_server(target, endpoints, serializer) self.rpcserver.start()
  • 15. Versioning ● Requires diligence (with some tools to help catch offenders) ● Backwards-compatible changes ● Recipients should honor old versions ● Senders can pre-backport to older versions ● Nova does this automatically, but simply pinning versions is an easy way
  • 16. class MyObject(base.VersionedObject): # … continued def obj_make_compatible(self, primitive, version): if version == ‘1.0’: del primitive[‘name’] obj = MyObject(id=123, name=’foo’, metadata={‘speed’: ‘88mph’}) prim = obj.obj_to_primitive(target_version=’1.0’) # Now prim won’t have the ‘name’ field oldobj = VersionedObject.obj_from_primitive(prim, context) self.assertFalse(oldobj.obj_attr_is_set(‘name’))
  • 17. Why do this? ● Get a better handle on what you’re sending over RPC and what happens if you change ● Decouples the database from services, allowing DB schema upgrades independent of object schemas ● Easy serialization without sacrificing rich typing and bundled methods
  • 18. Why not do this? ● Because it will magically solve upgrade problems (it won’t) ● Because you have a better way ● Because it doesn’t fit your model or process ● Because the name is too boring