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

controller should debounce reconcile requests #318

Closed
ctron opened this issue Sep 7, 2020 · 7 comments
Closed

controller should debounce reconcile requests #318

ctron opened this issue Sep 7, 2020 · 7 comments
Labels
help wanted Not immediately prioritised, please help! runtime controller runtime related

Comments

@ctron
Copy link
Contributor

ctron commented Sep 7, 2020

It looks to me as if the controller triggers exactly one event for each change that was detected on e.g. an "owned resource".

Assume you have 10 owned resources for each resource, and 10 managed resources. That makes 100 events and thus 100 reconciliations on the startup of an operator.

The same for scheduled/delayed reconcile outcomes.

IMHO the controller queue should queue up a reconcile request if there is no event yet scheduled for this resource, or if the scheduled event is further in the future than the new request.

EDIT: (clux): See #318 (comment)

@nightkr

This comment was marked as outdated.

@ctron

This comment was marked as resolved.

@nightkr

This comment was marked as resolved.

@ctron

This comment was marked as resolved.

@ctron

This comment was marked as resolved.

@clux clux added the runtime controller runtime related label Sep 8, 2020
@clux clux added the ergonomics ergonomics of the public interface label Nov 3, 2021
@clux clux changed the title [kube-runtime] controller should drop duplicate re-queue requests controller should drop duplicate re-queue requests Nov 3, 2021
@clux clux linked a pull request May 13, 2022 that will close this issue
@clux
Copy link
Member

clux commented Apr 7, 2023

Revisiting this old issue to ensure we are doing everything we can. Here is a brief overview of what we do:

For anything else there are still the standard approaches;

  • use annotations on secondary streams to set checkpoints for the reconciler
  • use status fields on the primary stream to create checkpoints for the reconciler
  • gate check in the reconciler work that is guaranteed to be done to avoid duplicate heavy work

but these approaches are scarier since you run the risk of creating less idempotent reconcilers that can get into bad states (reconciler thinks it is done, and you cannot re-trigger it because it gate checks itself out of correcting the problem).

Debouncing

I feel the key question left for this issue is:
Is our debouncing as good as it can be? Judging by the code comments, probably not, but this stuff is also hard.
Ideally we want classical debouncing behavior:

  • event comes in? schedule a reconciliation for the relevant object at now() + N seconds
  • another event comes in before reconciliation is due? reschedule, for now() + N seconds
  • N second elapses after last event? reconcile

5 seconds is probably OK given the heavy work that usually works, but if we ever manage to expose options for the Controller, then this would be a good thing to expose.

Leaving this open and resolving older comments that are now out of date.
If someone wants to look at refining this, or experiment, you are welcome to, otherwise going to leave this as is.

@clux clux removed the ergonomics ergonomics of the public interface label Apr 7, 2023
@clux clux changed the title controller should drop duplicate re-queue requests controller should debounce reconcile requests Apr 7, 2023
@clux clux added the help wanted Not immediately prioritised, please help! label Apr 7, 2023
@clux
Copy link
Member

clux commented Jul 10, 2023

Closing this. Better scoped issue about how to improve scheduler debouncing linked in #1247

@clux clux closed this as completed Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Not immediately prioritised, please help! runtime controller runtime related
Projects
Status: Done
Development

No branches or pull requests

3 participants