-
-
Notifications
You must be signed in to change notification settings - Fork 324
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 predicates
to allow filtering watcher
streams
#911
Conversation
Signed-off-by: clux <sszynrae@gmail.com>
This comment was marked as off-topic.
This comment was marked as off-topic.
Previous potential problems noted about using predicates for controllers that came up before and wanted to note them. That said, I no longer think they are objections worth blocking this for. Here are the problems that came up: 1. It inhibits requeues / retriggers / only accounts for the last objects in the controller's queue streamThe system is meant to requeue based on time, and allow users to re-trigger in case something bad happened, so it is essential that this is not filtered out at the controller level. The solution is to not do this filtering inside the controller; let users filter outside (via stream sharing), and always propagate requeues/retriggers. 2. It potentially encourages non-idempotent modes of operation of a reconcilerI.e. less redundant work scheduled, leads to people being lazier. Yes, true, but isn't that a good thing? It's also not like we are doing filtering across all streams with the same brush. This is intended to be setup in the way you want for each stream. EDIT: edited after more clarity, since it was the most matching comment. |
PoC on node_reflector to only show changed labels Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: Eirik A <sszynrae@gmail.com>
Signed-off-by: Eirik A <sszynrae@gmail.com>
Signed-off-by: Eirik A <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Wrapped this in an unstable feature and added better docs. Hoping to get this in so we can iterate if we find corner cases. I still have not found good ways to solve this, and other people keep asking about it. I think this can actually be useful with something like #1163 as an early place to experiment with stream sharing with stuff like #1163. cc @Dav1dde Deny will fail because of a dev-dep duplicate (it's fixed in #1171) |
Signed-off-by: clux <sszynrae@gmail.com>
predicates
to allow filtering watcher
streams
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Going to send this through under the unstable feature to let it stew for a while. This is a simplistic solution and may benefit from some TTL style decay (or moving it before the flatteners to get access to raw |
A re-implementation of the go predicates from controller-runtime that allows filtering
watcher
streams from a new (unstable)WatchStreamExt::predicate_filter
:This allows filtering out events that only changes (say) the status object. It contains a set of common extractor functions (under
runtime::predicates
) and operates throughPredicateFilter
. This stream utility contains a smallHashMap
with hashes of the last seen value for each object, and simply compares that value (from the extractor) with the one in the new watch event.notes and origin and discussion links
based on user predicates that allow short-circuiting `reconciler` runs if nothing important has changed:
see this commit which was used in the reconciler as an early exit gate via:
relying on passing an thread-safe
Evaluation
cache via thereconcile
context. This method has huge problems when used in controllers with more than one type, because this setup only filters based on the merged QueueStream. Crucially, if an owned object changes, it won't be captured in the root type, so you might miss important changes to child objects. Doing the check inside the reconciler is too late.So for controller usage we have to do predicate style filters on the watcher streams instead, and have users configure predicates PER stream, then pass them to the controller using stream sharing for this to work cohesively.