How Should We Model Versions, Schemas, and Conversions? #2598
Replies: 1 comment
-
re: Could we consider an option where we have the APIResourceSchema object be mutable? Some pre-requisites/assumptions:
Immutability today is required to control the rollout of an APIResourceSchema revision, if we allow APIResourceSchema objects to be mutable, the system could potentially offer revisions as part of an admission process. For example, Let's say that we have this schema (copied from test/e2e): [...]
- name: v1alpha1
schema:
description: Cowboy is part of the wild west
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CowboySpec holds the desired state of the Cowboy.
properties:
intent:
type: string
type: object
status:
description: CowboyStatus communicates the observed state of the Cowboy.
properties:
result:
type: string
type: object
type: object
[...] After the object is accepted: [...]
- name: v1alpha1
schema:
description: Cowboy is part of the wild west
properties:
apiVersion:
> revision: 1
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
> revision: 1
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
> revision: 1
type: object
spec:
> revision: 1
description: CowboySpec holds the desired state of the Cowboy.
properties:
intent:
> revision: 1
type: string
type: object
status:
> revision: 1
description: CowboyStatus communicates the observed state of the Cowboy.
properties:
result:
> revision: 1
type: string
type: object
type: object
[...] Let's say now, we add a new field to the existing [...]
- name: v1alpha1
schema:
description: Cowboy is part of the wild west
properties:
[...]
spec:
revision: 1
description: CowboySpec holds the desired state of the Cowboy.
properties:
fedora:
> revision: 2
type: bool
intent:
revision: 1
type: string
type: object
[...] In addition, the |
Beta Was this translation helpful? Give feedback.
-
@ncdc @vincepri and I were chatting about
APIResourceSchema
and the associated machinery and a thought came up - we want API rollout to be explicit and deterministic, so we require thatAPIResourceSchema
be immutable. This means that if an API hasN
versions, and I update just one of them to have a new field, I create an entirely newAPIResourceSchema
and copy lots of data. Similarly, the proposedAPIConversion
resource is also immutable has all the mappings required for anAPIResourceSchema
, so any minor change requires a lot of copying into a new object.What if we model things at a more granular level?
APIExport
references a set ofAPIResourceSchema
APIResourceSchema
references a set ofAPIResourceVersion
sAPIResourceVersion
provides the information necessary for a specific semantic version, at a particular point in time - e.g.v1
, from November 22ndThen, we can also have
APIConversion
objects that are uniquely identified by the twoAPIResourceVersion
objects they operate between - so eachAPIConversion
resource only provides the (bi)directional conversions between two specific versions.This would allow us to reduce the amount of noise and duplication in our API objects, as well as give us much more fine grained control over e.g. garbage collection, without changing the nice guarantees we have at the
APIExport
level.Beta Was this translation helpful? Give feedback.
All reactions