Skip to content

🐛 Fix informer cache creating pointers to pointers #667

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

Closed
wants to merge 1 commit into from
Closed

🐛 Fix informer cache creating pointers to pointers #667

wants to merge 1 commit into from

Conversation

DewaldV
Copy link
Contributor

@DewaldV DewaldV commented Oct 31, 2019

Fixes #656

It appears the code in controller-runtime/pkg/cache/informer_cache.go tries to determine whether the items can be cast to runtime.Object and in the process assumes that the slice's elements are not pointers.

This means that if you have a List whose Items type is []*Item the informer cache will create a cacheTypeValue of **Item which then cannot be case to runtime.Object resulting in an error of:

"error": "cannot get cache for *v1.PrometheusRuleList, its element **v1.PrometheusRule is not a runtime.Object"}

When the list type is already a pointer this code results in a cache type of **Type which can't be cast to runtime.Object.
This adds a check to the function to only grab a pointer to a type if it is not already a ptr type.
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 31, 2019
@k8s-ci-robot
Copy link
Contributor

Welcome @DewaldV!

It looks like this is your first PR to kubernetes-sigs/controller-runtime 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/controller-runtime has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @DewaldV. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 31, 2019
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 31, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: DewaldV
To complete the pull request process, please assign directxman12
You can assign the PR to them by writing /assign @directxman12 in a comment when ready.

The full list of commands accepted by this bot can be found 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

@DewaldV
Copy link
Contributor Author

DewaldV commented Oct 31, 2019

Hmm, my org has a signed CLA so I expected that check to pass. I'll try and see what's up with that before proceeding here.

@DewaldV
Copy link
Contributor Author

DewaldV commented Oct 31, 2019

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 31, 2019
@DewaldV
Copy link
Contributor Author

DewaldV commented Oct 31, 2019

Ok, that should be good now. Apologies for the lapse, I had missed a step when linking my GH account to our org's.

@DewaldV
Copy link
Contributor Author

DewaldV commented Oct 31, 2019

/assign @DirectXMan12

@alvaroaleman
Copy link
Member

@DewaldV thanks for your PR. Could you add a test for this so we don't regress?
/ok-to-test

And more of a comment, but pretty much all List types I've seen use a list of literals, not a list of pointers. The api conventions don't mention anything about that so I guess its fine.

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 31, 2019
@DewaldV
Copy link
Contributor Author

DewaldV commented Oct 31, 2019

@alvaroaleman Happy to, I'll get another commit with a test done in a bit.

@DewaldV
Copy link
Contributor Author

DewaldV commented Nov 5, 2019

Apologies for the delay on this, I've got a basic spike with the tests local but I've been delayed due to some work pressures. I'll try and get some time this week to get the test cleaned up and pushed.

DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
Updating double quotes in help text
@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 Feb 3, 2020
@DirectXMan12
Copy link
Contributor

hey, are you still interested in working on this

@DewaldV
Copy link
Contributor Author

DewaldV commented Feb 11, 2020

Apologies for the delay on this.

The testing turned out to be rather complicated as it required creating some CRDs with Lists that use pointers so I stalled in Nov and then it dropped off my radar.

I'm going to put some time aside to get the tests finished up over the coming week so we can get this merged.

We do still need it.

@alvaroaleman
Copy link
Member

@DewaldV I ended up needing as well, do you mind if I take your commit from here, add another one with a test on top of it and create a new PR so this gets done in a timely manner?

@DewaldV
Copy link
Contributor Author

DewaldV commented Feb 11, 2020

@alvaroaleman I'm happy with that. Appreciate you jumping in on this and apologies for not getting this merged before. 😄

@vincepri
Copy link
Member

Closing this in favor of 796

/close

@k8s-ci-robot
Copy link
Contributor

@vincepri: Closed this PR.

In response to this:

Closing this in favor of 796

/close

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
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to List Objects with pointer slices
6 participants