-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
Informer::init considered harmful? #134
Comments
Yeah, the The normal controller advice I've seen is to periodically loop through everything and reconcile their state in an idempotent way. However, you don't really get to do that unless you have the state elsewhere, like in a Reflector. So currently, to do the right thing you'd need both, and periodically reconcile what's inside of the Reflector, while also handling events. It's not a great pattern atm. Considering writing a more robust |
If you don't care about the cache (and arguably you shouldn't, given that K8s doesn't have transactions..) then an uninitialized |
After looking a bit closer, It would be nice to at least have a conservative mode, where it prefers sending extra duplicate events over losing anything. |
I'm not sure I understand. Desyncs typically happens due to a 410 Gone from the apiserver, if that happens, we do lose events. Not really sure what we can do about it in this apart from implementing bookmark stuff from kube>=1.15 (see #54), but maybe I misunderstand what you are proposing. |
There are two different options when desyncs happen:
Approach 2 still has a few implications:
Currently |
Ohh, I see. I didn't realise the events we got from version zero actually contains at least one event for every resource. This makes approach 2 a lot more reasonable, even if boot becomes a bit heavier. 👍
Yeah, that is pretty in-line with k8s controller writing advice. We should possibly erase the distinction for even Delete events. But that's a pretty opinionated thing to do: This is what I imagine a Controller type struct - built on top Informer - would excel at. It could take a If we just stop following approach 1, in Informer, then we could have all the flexibility and have a best-practice approach. I like the idea of advocating for finalizers as well. Either that, or the Controller driving app should diff third party state against kube state periodically to catch deleted resources. |
It's funny that the kubernetes docs say kind of the opposite in https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes
|
From what I can tell, those docs essentially say:
|
Takes "approach 2" from kube-rs#134 (comment), see the noted caveats. Deletes Informer::init, since it is no longer useful.
init removed in 0.27.0. See #148 for a controller runtime. |
Any use case that I can see will be prone to race conditions. In particular:
Reflector
!": You'll miss any changes that happen betweenReflector::init
andInformer::init
. There is also no guarantee that theReflector
will be up to date if you try to read from it from theInformer
.It's also somewhat confusing that
Reflector::init
is required for it to be useful, whileInformer::init
will mostly be a source of bugs.The text was updated successfully, but these errors were encountered: