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

Add generic helpers to kube-core #428

Open
5 of 10 tasks
clux opened this issue Feb 21, 2021 · 6 comments
Open
5 of 10 tasks

Add generic helpers to kube-core #428

clux opened this issue Feb 21, 2021 · 6 comments
Labels
core generic apimachinery style work help wanted Not immediately prioritised, please help!

Comments

@clux
Copy link
Member

clux commented Feb 21, 2021

Lots of use cases for adding helpers when dealing with common interfaces like:

This issue is an umbrella issue to cross-link utils, plus a place to discuss a possible feature'd module in kube, or a kube-utils crate.

@clux clux added the utils extra utility modules label Feb 21, 2021
@clux clux changed the title Api Utilities helper module/crate Add generic helpers to kube-core Jun 26, 2021
@clux clux added core generic apimachinery style work help wanted Not immediately prioritised, please help! and removed utils extra utility modules labels Jun 26, 2021
@MatteoJoliveau
Copy link

Hi @clux, reviving this old issue to inquire regarding its status, specifically about helpers for owner refs.

I've been porting a subset of controllerutils to Rust to implement functions like set_controller_reference and set_owner_reference in a project and would love to donate the code to kube-rs. Would you be interested in a PR?

@clux
Copy link
Member Author

clux commented Feb 9, 2022

Yeah, helpers like that would be very much appreciated! I think we have some logic like this already inside the finalizer helper that is utilizing jsonpatches. I personally always wanted that stuff to be a bit easier, at least for standard stuff, so implementations / sketches / ideas here here would be welcome.

Thinking this stuff would probably live in the core crate (if it's using jsonpatch), and then re-used down the line (e.g. the finalizer helper). If it's in core i am sure it would attract a bit of bikeshedding though :D

@MatteoJoliveau
Copy link

My helpers do not interact with any API by themselves. They're a straight port of controllerutil and only modify the Resource.

For instance here is the signature for set_controller_reference

fn set_controller_reference<O: Resource, K: Resource>(owner: &O, controlled: &mut K,) -> Result<(), AlreadyOwnedError>

@clux clux mentioned this issue Feb 9, 2022
@clux
Copy link
Member Author

clux commented Feb 9, 2022

Ah, that type of module would also probably work inside core, not what I expected, but it's probably easier than combining json patches, and it's a clever signature.

@nightkr
Copy link
Member

nightkr commented Feb 9, 2022

Yeah.. I think finalizers are a kind of special case, since they have "fun" timing requirements (the finalizer MUST be acknowledged by K8s BEFORE we start performing work that they'd clean up, and so on). Most should be fine to just integrate with the regular batching.

@johanfleury
Copy link

johanfleury commented Sep 29, 2024

It would be nice to have ports of controllerutil.ContainsFinalizer(obj, finalizerName) and controllerutil.AddFinalizer(obj, finalizerName).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core generic apimachinery style work help wanted Not immediately prioritised, please help!
Projects
None yet
Development

No branches or pull requests

4 participants