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

Deprecate default conversions #90018

Merged

Conversation

wojtek-t
Copy link
Member

@wojtek-t wojtek-t commented Apr 9, 2020

Ref #87006

This switches off the path for default conversions - from now on, only explicitly registered conversions work.

k8s.io/apimachinery - scheme.Convert() now uses only explicitly registered conversions - default reflection based conversion is no longer available. `+k8s:conversion-gen` tags can be used with the `k8s.io/code-generator` component to generate conversions.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 9, 2020
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 9, 2020
// conversions

if pair.source == pair.dest {
// TODO: Ideally, to avoid this hack, we should auto-generate self-conversions.
Copy link
Member

@liggitt liggitt Apr 9, 2020

Choose a reason for hiding this comment

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

include the EnforcePtr(src) and EnforcePtr(dest)/CanAddr/CanSet checks here?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@fejta-bot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@lavalamp
Copy link
Member

lavalamp commented Apr 9, 2020

/assign @yliaog @deads2k

@fejta-bot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/check-cla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 9, 2020
@wojtek-t wojtek-t force-pushed the deprecate_default_conversions branch from 3573976 to c71ee41 Compare April 10, 2020 12:10
@wojtek-t wojtek-t force-pushed the deprecate_default_conversions branch 2 times, most recently from eb9bb82 to 7b6e7b8 Compare April 10, 2020 14:11
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2020
@wojtek-t wojtek-t force-pushed the deprecate_default_conversions branch from 7b6e7b8 to 4b6105e Compare April 10, 2020 14:42
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wojtek-t

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 sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Apr 10, 2020
@wojtek-t wojtek-t force-pushed the deprecate_default_conversions branch from 4b6105e to f624314 Compare April 10, 2020 15:03
@wojtek-t
Copy link
Member Author

/retest

@wojtek-t wojtek-t added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 10, 2020
@deads2k
Copy link
Contributor

deads2k commented Apr 13, 2020

/hold

I'd like a chance to have a look at this and judge impact. I expect to have an answer back this week. The PR itself looks pretty contained, but it's relying on a fair number of 1.18 PRs so it will take me a bit.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 13, 2020
@deads2k
Copy link
Contributor

deads2k commented Apr 22, 2020

Well, it's not great, but it looks tractable. Looks like a dozen unique bits or so openshift/openshift-apiserver#95

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 22, 2020
@liggitt
Copy link
Member

liggitt commented Apr 23, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 23, 2020
@k8s-ci-robot k8s-ci-robot merged commit 775feed into kubernetes:master Apr 23, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Apr 23, 2020
@liggitt
Copy link
Member

liggitt commented Apr 23, 2020

this needs a release note for k8s.io/apimachinery use, pointing at conversion-gen or something similar

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 23, 2020
@wojtek-t
Copy link
Member Author

this needs a release note for k8s.io/apimachinery use, pointing at conversion-gen or something similar

@liggitt - Added something - PTAL

wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 30, 2020
Protecting us from [1,2]:

  converting (v1beta1.Role) to (v1.Role): unknown conversion

in unit tests.  The manual conversion and wash through JSON seems like
a terrible hack, but I haven't been able to figure out a more elegant
approach yet.  From [3]:

  Promotes the rbac.authorization.k8s.io/v1beta1 API to v1 with no changes

so all we really need is the apiVersion bump.

[1]: kubernetes/kubernetes#90018
[2]: openshift#420 (comment)
[3]: kubernetes/kubernetes#49642
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 30, 2020
Protecting us from [1,2]:

  converting (v1beta1.Role) to (v1.Role): unknown conversion

in unit tests.  The manual conversion and wash through JSON seems like
a terrible hack, but I haven't been able to figure out a more elegant
approach yet.  From [3]:

  Promotes the rbac.authorization.k8s.io/v1beta1 API to v1 with no changes

so all we really need is the apiVersion bump.

[1]: kubernetes/kubernetes#90018
[2]: openshift#420 (comment)
[3]: kubernetes/kubernetes#49642
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 30, 2020
Protecting us from [1,2]:

  converting (v1beta1.Role) to (v1.Role): unknown conversion

in unit tests.  The manual conversion and wash through JSON seems like
a terrible hack, but I haven't been able to figure out a more elegant
approach yet.  From [3]:

  Promotes the rbac.authorization.k8s.io/v1beta1 API to v1 with no changes

so all we really need is the apiVersion bump.

Also add similar logic for apiregistration, since that's the other
group where we register multiple schema versions.

[1]: kubernetes/kubernetes#90018
[2]: openshift#420 (comment)
[3]: kubernetes/kubernetes#49642
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 31, 2020
Protecting us from [1,2]:

  converting (v1beta1.Role) to (v1.Role): unknown conversion

Because merging and application are also version-dependent, it's hard
to paper over this in resourceread with automatic type conversion.
Although from [3]:

  Promotes the rbac.authorization.k8s.io/v1beta1 API to v1 with no changes

so all we really need is the apiVersion bump.  Anyhow, with this
commit, I'm doubling down on the approach from 4ee7b07 (Add
apiextensions.k8s.io/v1 support for CRDs, 2019-10-22, openshift#259) and
collapsing the readers into two helpers that support all of our types
and return runtime.Object.

From 0a255ab (cvo: Use protobuf for sending events and other basic
API commands, 2019-01-18, openshift#90), protobuf is more efficient, so we
should use it where possible.

And because all of this is very tedious to maintain by hand, there's
now a Python generator to spit out all the boilerplate.

[1]: kubernetes/kubernetes#90018
[2]: openshift#420 (comment)
[3]: kubernetes/kubernetes#49642
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 31, 2020
Protecting us from [1,2]:

  converting (v1beta1.Role) to (v1.Role): unknown conversion

Because merging and application are also version-dependent, it's hard
to paper over this in resourceread with automatic type conversion.
Although from [3]:

  Promotes the rbac.authorization.k8s.io/v1beta1 API to v1 with no changes

so all we really need is the apiVersion bump.  Anyhow, with this
commit, I'm doubling down on the approach from 4ee7b07 (Add
apiextensions.k8s.io/v1 support for CRDs, 2019-10-22, openshift#259) and
collapsing the readers into two helpers that support all of our types
and return runtime.Object.

From 0a255ab (cvo: Use protobuf for sending events and other basic
API commands, 2019-01-18, openshift#90), protobuf is more efficient, so we
should use it where possible.

And because all of this is very tedious to maintain by hand, there's
now a Python generator to spit out all the boilerplate.

[1]: kubernetes/kubernetes#90018
[2]: openshift#420 (comment)
[3]: kubernetes/kubernetes#49642
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. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants