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

ResettableRESTMapper to make it possible to reset wrapped mappers #105623

Merged
merged 1 commit into from
Nov 17, 2021

Conversation

ash2k
Copy link
Member

@ash2k ash2k commented Oct 12, 2021

What type of PR is this?

/kind cleanup
/sig api-machinery
/sig cli

What this PR does / why we need it:

Having a proper API to reset a REST mapper is useful:

  1. As it is seen in this PR, garbage collector uses this functionality.
  2. cli-util uses this functionality via reflection here (see also Bug: apply sets that include both CRD and CR fail when not using a caching RestMapper kubernetes-sigs/cli-utils#421 (comment)).

Currently those implementations are fragile as if a mapper is wrapped, it becomes impossible to reset it properly (i.e. reset the delegate).

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/cli Categorizes an issue or PR as relevant to SIG CLI. labels Oct 12, 2021
@k8s-ci-robot
Copy link
Contributor

@ash2k: The label(s) sig/apimachinery cannot be applied, because the repository doesn't have them.

In response to this:

What type of PR is this?

/kind cleanup
/sig apimachinery
/sig cli

What this PR does / why we need it:

Having a proper API to reset a REST mapper is useful:

  1. As it is seen in this PR, garbage collector uses this functionality.
  2. cli-util uses this functionality via reflection here (see also Bug: apply sets that include both CRD and CR fail when not using a caching RestMapper kubernetes-sigs/cli-utils#421 (comment)).

Currently those implementations are fragile as if a mapper is wrapped, it becomes impossible to reset it properly (i.e. reset the delegate).

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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. labels Oct 12, 2021
@fedebongio
Copy link
Contributor

/assign @yliaog
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 12, 2021
@ash2k ash2k force-pushed the ash2k/resettable-rest-mapper branch from 71a1ae7 to 496de42 Compare October 13, 2021 05:15
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 13, 2021
@ash2k ash2k requested a review from yliaog October 13, 2021 05:18
@ash2k
Copy link
Member Author

ash2k commented Oct 13, 2021

/retest

@yliaog
Copy link
Contributor

yliaog commented Oct 13, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2021
@ash2k
Copy link
Member Author

ash2k commented Oct 13, 2021

/assign @deads2k

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2021
@ash2k ash2k force-pushed the ash2k/resettable-rest-mapper branch from 496de42 to de4598d Compare November 5, 2021 23:45
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 5, 2021
@ash2k
Copy link
Member Author

ash2k commented Nov 5, 2021

@deads2k PTAL

@ash2k
Copy link
Member Author

ash2k commented Nov 7, 2021

@seans3 I wonder what can be done to get this merged before 1.23 freeze (November 16th). I'd like to use it in cli-utils instead of the reflection hack.

Copy link
Contributor

@seans3 seans3 left a comment

Choose a reason for hiding this comment

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

For SIG CLI:

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2021
@yliaog
Copy link
Contributor

yliaog commented Nov 15, 2021

/approve

@@ -519,3 +519,12 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string
}
return mappings, nil
}

// MaybeResetRESTMapper calls Reset() on the mapper if it is a ResettableRESTMapper.
func MaybeResetRESTMapper(mapper RESTMapper) bool {
Copy link
Member

Choose a reason for hiding this comment

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

naive question, it seems the bool output is never used , is it worth having it?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not used at the moment, but may be used in the future, including by users of this library. I'm more than happy to remove it if this will increase chances of the PR getting merged.

Copy link
Member

Choose a reason for hiding this comment

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

no no, I was curious only, wait for the maintainers opinion

Copy link
Member

Choose a reason for hiding this comment

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

let me ping @liggitt

Copy link
Contributor

Choose a reason for hiding this comment

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

My preference is to not have it.

Copy link
Contributor

Choose a reason for hiding this comment

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

My preference is to not have it.

Given timing, I'm willing to take the removal of this bool as a followup.

Copy link
Member Author

Choose a reason for hiding this comment

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

@deads2k
Copy link
Contributor

deads2k commented Nov 16, 2021

/approve
/milestone v1.23

@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Nov 16, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ash2k, deads2k, seans3, yliaog

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 Nov 16, 2021
@ash2k
Copy link
Member Author

ash2k commented Nov 16, 2021

@deads2k Thank you very much! I'll open a followup to remove the return value today (to be merged later).

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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. 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/cli Categorizes an issue or PR as relevant to SIG CLI. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants