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

🐛 Allow lazy restmapper to work with CRDs created at runtime #2208

Merged
merged 1 commit into from Mar 1, 2023

Conversation

Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Feb 22, 2023

Now lazy restmapper fetches all API resources once at start and then caches them. It prevents it from discovery of new CRDs created after the controller has started.
This PR allows lazy restmapper to work with such CRDs.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 22, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 22, 2023
@alvaroaleman alvaroaleman changed the title 🐛 Allow lazy restmapper to work with CRDs created in runtime 🐛 Allow lazy restmapper to work with CRDs created at runtime Feb 22, 2023
pkg/client/apiutil/lazyrestmapper_test.go Outdated Show resolved Hide resolved

m.apiGroups = apiGroups
// It will make 2 API calls to /api and /apis respectively.
apiGroups, err := m.client.ServerGroups()
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we cache this and only re-fetch if the cached serverGroups don't have the requested groupName?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I returned caching here again. Now we just update it when nothing was found.

pkg/client/apiutil/lazyrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/lazyrestmapper.go Outdated Show resolved Hide resolved
Now lazy restmapper fetches all API resources once at start and then
caches them. It prevents it from discovery of new CRDs created after
the controller has started.
This commit allows lazy restmapper to work with such CRDs.
@Fedosin
Copy link
Contributor Author

Fedosin commented Feb 25, 2023

/test pull-controller-runtime-test

1 similar comment
@Fedosin
Copy link
Contributor Author

Fedosin commented Feb 26, 2023

/test pull-controller-runtime-test

@vincepri
Copy link
Member

vincepri commented Mar 1, 2023

/lgtm
/assign @sbueringer

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 1, 2023
@vincepri
Copy link
Member

vincepri commented Mar 1, 2023

/cherry-pick release-0.14

@k8s-infra-cherrypick-robot

@vincepri: once the present PR merges, I will cherry-pick it on top of release-0.14 in a new PR and assign it to you.

In response to this:

/cherry-pick release-0.14

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.

@sbueringer
Copy link
Member

Thx for the fix!

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Fedosin, sbueringer

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 Mar 1, 2023
@k8s-ci-robot k8s-ci-robot merged commit e2d8821 into kubernetes-sigs:main Mar 1, 2023
@k8s-infra-cherrypick-robot

@vincepri: #2208 failed to apply on top of branch "release-0.14":

Applying: Allow lazy restmapper to work with CRDs created in runtime
Using index info to reconstruct a base tree...
M	pkg/client/apiutil/lazyrestmapper_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/client/apiutil/lazyrestmapper_test.go
CONFLICT (content): Merge conflict in pkg/client/apiutil/lazyrestmapper_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Allow lazy restmapper to work with CRDs created in runtime
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-0.14

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.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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