Skip to content
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

WIP - apiextensions: low-level converter wiring – towards versioning #63802

Closed

Conversation

sttts
Copy link
Contributor

@sttts sttts commented May 14, 2018

  • add crdConversionRESTOptionsGetter to wire in custom conversions in storage path
  • wire through custom conversions in serializers for request de- and encoding.

@k8s-ci-robot
Copy link
Contributor

@sttts: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 14, 2018
@sttts sttts added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 14, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2018
@sttts sttts force-pushed the sttts-crd-versioning-low-level-plumbing branch from 6124d37 to 393bdc6 Compare May 14, 2018 14:43
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 14, 2018
@sttts sttts force-pushed the sttts-crd-versioning-low-level-plumbing branch 2 times, most recently from 40ed457 to 8834b09 Compare May 14, 2018 14:48
@sttts
Copy link
Contributor Author

sttts commented May 14, 2018

/cc @mbohlool

}
if targetGVK == objGVK {
return c.encoder.Encode(obj, w)
// Only avoid conversion if unstructured is not a list, giving the converter a chance to convert list items.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When did you find a list that asserted the "correct" group/version, but actually contained types in the wrong group/version?

@@ -59,7 +59,7 @@ func newStorage(t *testing.T) (customresource.CustomResourceStorage, *etcdtestin
&metav1.DeleteOptions{},
)

typer := apiserver.UnstructuredObjectTyper{
typer := apiserver.unstructuredObjectTyper{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't compile, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't. We shouldn't leak from the apiserver into the registry in the first place though.

@@ -126,6 +126,8 @@ func NewCRDRESTOptionsGetter(etcdOptions genericoptions.EtcdOptions) genericregi
EnableGarbageCollection: etcdOptions.EnableGarbageCollection,
DeleteCollectionWorkers: etcdOptions.DeleteCollectionWorkers,
}

// the codec is going to be overridden with the actual CRD converter based codec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a per-group basis? Please specify the granularity.

ret.StorageConfig.Codec,
t.converter,
&unstructuredCreator{},
discovery.NewUnstructuredObjectTyper(nil),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder to myself, I promised to move this to the extensions apiserver because it's the only consumer and it's misnamed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to move all of these into a scheme package here.

// and custom encoder and decoder version.
type crdConversionRESTOptionsGetter struct {
delegate generic.RESTOptionsGetter
converter runtime.ObjectConvertor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please doc granularity. All CRDs or one group? or something else?

in.GetObjectKind().SetGroupVersionKind(gvk)

for i := range unstructList.Items {
out, err := c.unstructuredDelegate.ConvertToVersion(&unstructList.Items[i], target)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird to directly delegate instead of recursing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't recurse because the underlying converter will be different (think of declarative conversion some day). Hence, we make this composition, so the generic crd converter can call the delegate converter doing the actual work on non-lists.

func (c crdObjectConverter) ConvertToVersion(in runtime.Object, target runtime.GroupVersioner) (runtime.Object, error) {
kind := in.GetObjectKind().GroupVersionKind()
if kind.Empty() {
return in, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does an empty kind result in no action instead of an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the analysis and a possible fix: mbohlool#5

unstructured.UnstructuredObjectConverter
clusterScoped bool
unstructuredDelegate unstructured.UnstructuredObjectConverter
clusterScoped bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cruft?

UnstructuredTyper: discovery.NewUnstructuredObjectTyper(),
typer := unstructuredObjectTyper{
delegate: parameterScheme,
unstructuredTyper: discovery.NewUnstructuredObjectTyper(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on its way to being a lot more opinionated. How about starting a scheme package or some such?

@deads2k
Copy link
Contributor

deads2k commented May 14, 2018

I think I see where you're going with it. It makes sense.

Can you summarized the intent in the description? It appears to me that you're working towards building a mutable object converter that is going to be used inside of the "normal" codec flow and will thus allow you to take a lock and change the converter as needed.

@deads2k
Copy link
Contributor

deads2k commented May 14, 2018

@kubernetes/sig-api-machinery-misc @lavalamp

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label May 14, 2018
@sttts sttts force-pushed the sttts-crd-versioning-low-level-plumbing branch from 8834b09 to b0f33ff Compare May 14, 2018 18:44
@lavalamp
Copy link
Member

/assign @mbohlool

@k8s-ci-robot
Copy link
Contributor

@sttts: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce-device-plugin-gpu e9599ad link /test pull-kubernetes-e2e-gce-device-plugin-gpu
pull-kubernetes-e2e-kops-aws e9599ad link /test pull-kubernetes-e2e-kops-aws
pull-kubernetes-bazel-build e9599ad link /test pull-kubernetes-bazel-build
pull-kubernetes-bazel-test e9599ad link /test pull-kubernetes-bazel-test
pull-kubernetes-e2e-gce e9599ad link /test pull-kubernetes-e2e-gce
pull-kubernetes-integration e9599ad link /test pull-kubernetes-integration
pull-kubernetes-kubemark-e2e-gce e9599ad link /test pull-kubernetes-kubemark-e2e-gce
pull-kubernetes-node-e2e e9599ad link /test pull-kubernetes-node-e2e
pull-kubernetes-typecheck e9599ad link /test pull-kubernetes-typecheck
pull-kubernetes-verify e9599ad link /test pull-kubernetes-verify

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@lavalamp
Copy link
Member

Can this be rebased on top of #63830? Or is it trying to be an alternative approach?

@sttts sttts changed the title apiextensions: low-level converter wiring – towards versioning WIP - apiextensions: low-level converter wiring – towards versioning May 15, 2018
@k8s-ci-robot
Copy link
Contributor

@sttts: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 15, 2018
@deads2k
Copy link
Contributor

deads2k commented May 15, 2018

Can this be rebased on top of #63830? Or is it trying to be an alternative approach?

My read is that this is doing the underlying wiring that is logically needed in #63830 and @sttts is helping actually do it instead of simply pushing a many comments into the pull.

@sttts
Copy link
Contributor Author

sttts commented May 15, 2018

My read is that this is doing the underlying wiring that is logically needed in #63830

Yes, this is 90% the same code as in #63830, minus adding the multiple versions. The goal was to iterate quicker with reviews than mixing lower level plumbing with API discussion in a big API implementing PR. The later takes a magnitude longer for review and to get it merged. Also having some soak time for those low-level changes at the heart of CRDs wouldn't harm.

These changes here are also blocking work on pruning and defaulting, which puts it on the critical path towards code-freeze (and with pruning being prerequisite for GA also for promotion of CRDs).

I don't feel strongly about which PR we finally merge (code is mostly the same), as long as we get it in this week. So if we put enough priority on #63830 both for review and for addressing comments, that's fine as well.

@k8s-ci-robot
Copy link
Contributor

@sttts: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 26, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 24, 2018
@sttts sttts closed this Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants