-
Notifications
You must be signed in to change notification settings - Fork 71
Support granular<->atomic schema changes #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support granular<->atomic schema changes #170
Conversation
|
@apelisse I'll look into if what is required to have an atomic clear nested managed fields from other field managers when applied. |
Correct. If we look at both cases (going from atomic to non-atomic and vice versa), both should probably generate a conflict:
Trying to see what happens on HA clusters that have multiple versions ... I don't think it has additional consequences beside the typical "things are blurry during transition". |
382e16c to
82b7e0f
Compare
|
Let me know when I should take a look, thanks :-) |
82b7e0f to
e965b91
Compare
411eaee to
eb03fad
Compare
5157704 to
9664c45
Compare
1042d0a to
b4bff7c
Compare
|
@apelisse This is ready for review. |
|
@apelisse to close the loop on the case of handling atomic->granular schema changes. I was concerned that it might be possible to mis-interpret a field set that is already granular as atomic if the fieldset only owned the root of a map/list but not any of it's children (i.e. |
b4bff7c to
c4315fe
Compare
c4315fe to
90b911a
Compare
|
@jennybuckley if you have any extra review bandwidth, this one could use some extra eyes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a couple of minor questions
merge/update.go
Outdated
| return newObject, managers, nil | ||
| } | ||
|
|
||
| // reconcileManagedFieldsWithSchemaChanges reconciles the managed fields with any changes to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit: can you move that below "update/apply" methods.
merge/update.go
Outdated
| if err != nil { | ||
| return nil, err | ||
| } | ||
| reconciled, err := typed.ReconcileFieldSetWithSchema(versionedSet.Set(), tv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if we really need the live object for that? Can't we fix each manager set by merely looking at the current type information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not asking you to change anything, just curious if we considered that and if that's any better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we need the live type is that when we go from atomic to granular, we need to add to the fieldset all the fields that exist in the live object under the field that was previously atomic. We don't know exactly what they are just from the schema, because we don't know which fields are absent, or which map keys or list items are present.
typed/reconcile_schema.go
Outdated
| return result, nil | ||
| } | ||
|
|
||
| func prefixWithPath(prefix fieldpath.Path, set *fieldpath.Set) *fieldpath.Set { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes me a little sad, there's probably a better way to do that :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've switched to constructing the new field path in a more direct way that doesn't require the prefixing.
| string: "b" | ||
| `, | ||
| APIVersion: "v1", | ||
| Managed: fieldpath.ManagedFields{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
|
Thanks for the review @apelisse! Feedback applied. |
f1d2e49 to
9a22ec6
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, jpbetz The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| return node, ok | ||
| } | ||
|
|
||
| func descendToPath(node *fieldpath.Set, path fieldpath.Path) *fieldpath.Set { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit for next time we look at it, this code should probably live in fieldpath rather than here.
|
We also probably need to cherry-pick this in as many versions as we can :-( |
Roger that. |
xref: Design proposal
WARNING: All merge type changes are backward incompatible! The functionality this PR provides is intended to reduce the pain caused should a merge type change need to be made (in a alpha API for example, or in a CRD where the author has control of all clients and is able to ensure the change is safe). This should be used with caution.
Enables developers to add/remove these tags to Kubernetes types, by reconciling existing managed field data with the schema change:
The corresponding x-kubernetes OpenAPI annotations for CRDs are also supported.
Need to do more careful benchmarking in k8s, but a simple benchmark in SMD suggests a 3.8% bump in CPU utilization and less than a 0.5% bump in allocations. The low allocation number is expected because the traversal is read-only unless there is an actual reconciliation change to apply afterward.
Before:
After:
Unblocks kubernetes/kubernetes#92913 and kubernetes/kubernetes#91256.
xref kubernetes/kubernetes#93901 which enables
structType=atomicusage in k8s