-
Notifications
You must be signed in to change notification settings - Fork 1.2k
✨ add EnqueueRequestForAnnotation enqueues Requests based on the presence of an annotation to watch resources #892
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
Conversation
f9ef112
to
fec8c8a
Compare
/assign @vincepri |
Can't this be a predicate on the watch? |
Hi @vincepri,
Thank you for your input. However, to do a predicate on the watch we still needing the ownership. Am I right? Note that:
I added more info in the first comment. Please, let me know if it makes more sense now and if you `re ok with. |
@camilamacedo86 The |
If you get a For example:
|
@vincepri So the answer is, yes, this could be done with existing handler and predicate features. The question we need to answer is whether the problem this handler sets out to solve is widespread enough that the controller-runtime community would find enough value in it to justify its addition here. This solution isn't perfect though.
|
ebd6fd5
to
b86aace
Compare
3afd8b0
to
7d3c6c9
Compare
b2adbfc
to
29abc88
Compare
f23d2fd
to
2cc696d
Compare
c949ce4
to
0289d80
Compare
/assign @mengqiy |
…ce of an annotation to watch resources
0289d80
to
00c220a
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: camilamacedo86 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 |
/assign @mengqiy |
I have a bit of a feeling that this change is a bit of a workaround for multiple problems: For a), I think this is a totally solvable problem, it just seems that no one bothered to do that yet (We had a bunch of downstream code for this in a different project but didn't upstream it) For b), I think we should first have a discussion with sig-apimachinery if this is something that just isn't possible today or something that will never be possible. If the latter, we should spend a bit of time on thinking about nice api that replaces ownerRefs for that case. One problem I see for example with the current approach is that at most one owner can be declared. Also, I am not a huge fan of putting the burden of remembering to set finalizers and cleaning up objects if their parents are gone (AKA: build a custom garbage collector controller) onto the users of c-r. |
Hi @alvaroaleman, So, if I understood you are ok with move with it but you also would like to see customization/rfe in the garbage collector controller in order to NOT be required to work with finalizers. I mean, allow it also remove the chields based on the annotations. Am I right? Could we work to do this improvement in a follow-up? WDYT? |
Sorry I don't understand what you mean by that? But no, I am not a fan of this right now because:
|
HI @alvaroaleman,
Could you please let me know where we can add a design doc about this? Also, when you say that
Over it, what in your point of view what is missing for we are able to clarify it? As you said:
So would not it be a valid reason to incorporate to upstream? |
I think before we start implementing something that is only needed because upstream does not support a certain feature we should:
The reason is apparently that:
Source: https://kubernetes.slack.com/archives/C0EG7JC6T/p1587388988464000 The get info part definitely applies to us, the block owner part might apply, depending on how ppl implement garbage collection (Which they shouldn't need to do in the first place). Can you please start a discussion with upstream sig-apimachinery if there is anything that can be done to support an usecase like this in a safe manner? /hold |
We are closing this one. Based on the feedback shows that it would not be generic enough to upstream. |
I was thinking about this PR when I needed to write a controller that reconciled on k8s The
|
Story
As an operator developer, it would be nice to be able to watch dependent resources based on the presence of an annotation in the dependent resource.
Description
While owner references are the idiomatic way to manage dependent resources, they don't solve all use cases. Owner references have restrictions that limit which objects can own other objects.
An annotation-based watch handler does not have these restrictions. However, they don't provide the same feature set either.
The watch handler can be used to trigger reconciliation of a parent resource based on changes to dependent resources that include an annotation. The purpose of this handler is to support cross-scope ownership relationships that are not supported by native owner references.
Since this is a niche feature that should only be used in specific circumstances. Note that for example, owner references are used for garbage collection. If a resource's owner is deleted, the resource will also be deleted. Because of this, annotation references need to be paired with a finalizer so that the operator can manually garbage collect.
Example
Closes: kubernetes-sigs/kubebuilder#888