-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Subresource status failing to stop infinite loop #2795
Comments
This is the way Kubernetes control loops are intended to work. Whenever a change occurs in your CR, it will trigger an event to reconcile your CR again. To solve your problem, you can either use a predicate (e.g. the GenerationChangedPredicate that ignores status updates), or you can make sure you only ever update your CR status We'll take an action to see if some documentation needs to be updated to make this more clear. |
@joelanford I'm very confused then. The docs specifically say:
Is this not specifically saying that this is not the way the control loop should work when updating a subresource (as opposed to a normal resource)? I can't see any other way to read this, and I have found the same sentiment documented in a number of places. |
EDIT: This was not correct. Thanks @raffaelespazzoli for the clarification. |
@joelanford Thanks for the explanation! I assume those docs aren't open source, otherwise I'd offer to help. I'll look into the other options you provided. Thanks again! |
let me try to clarify. By using status as subresource, when we upgrade just the status with this syntax: |
@raffaelespazzoli Thanks for the clarification. I was getting mixed up in my previous comments. So TL;DR (and to make sure my understanding is now correct) 🙂
|
point #2 is wrong. generation is increased by the apiserver every time something changes in a resource (but not if it changes in a subsresource). |
Bug Report
What did you do?
A clear and concise description of the steps you took (or insert a code snippet).
As documented here, in order to avoid CR status changes causing an infinite loop of the reconcile() function, we should make the
status
block a subresource, following steps outlined here.However, we have found that even though we successfully set the CRD status attribute as a subresource, we still see infinite looping of reconcile() when status is changed. A simple example to reproduce, using the canonical PodSet operator demo, would have the following types spec:
which results in a CRD with a subresource, as expected:
However, placing the following code in the controller reconcile() function:
This updates the 'Updated' timestamp on the status object every time reconcile() is called. According to the documentation, this change to the status object should not trigger a call of the reconcile() function because the status object is a subresource, thus avoiding an infinite loop. However, the infinite loop occurs. Is the documentation wrong, is there a bug, or am I missing something?
What did you expect to see?
When setting the 'status' attribute as a subresource of a CRD, I should be able to update status in the reconcile() function without re-invoking the reconcile() loop.
What did you see instead? Under which circumstances?
When updating the status attribute, even though its a subresource, I see an infinite loop of the reconcile() function.
Environment
Kubernetes cluster kind: openshift
Are you writing your operator in ansible, helm, or go? go
Possible Solution
Additional context
I've created a functional reproduction of the issue in this repo
The text was updated successfully, but these errors were encountered: