-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
The Store API is not writable #3968
Comments
Yes that was intentional to avoid ad hoc modifications to the store state.
Something like Informable.withLastKnownState(Iterator items)? Or are you looking to make other modifications? This is also somewhat related to #3943 which internally creates a customizable ItemStore. In your case it should like you would potentially want to plug-in a database backed store. |
Our current code use the We also manipulate the cache in the event handler hooked to the informer. If there is an error in the side effect of the event (basically an error writing in the database), we push back in the cache the original value. It reverts the update of the cache and we have a chance to reapply the update later, with a later resync. If we don't do that, we won't recover the error until the informer is restarted, so not until our application restart. |
This changes the notion of the informer store from being representative of the api server state, to instead being the desired state of your database. An update (or resync) to that pushed back resource emit an update event that will only completely make sense to your database event handler. Any cache modifications mean that all handlers added to the informer must understand the semantics of those modifications in terms of the events they are receiving. I was hoping to avoid these kind of situations because of the coupling between the store and event handlers. What you are describing could be done without modifying the store:
At worst that may process the same update twice, but it won't miss any events. |
In our code the informer and its handler are tighly coupled. But I understand the rationale of restricting the Store API. |
Adding to the 6.x milestone for the creation of a withLastKnownState method. |
…mers opening back up to store modifications - but they are atomic and based upon resourceVersion also stop emiting sync events on relist (which was a natural result of the first changes) and several other informer related changes
A possible change for this is on #3981 - that adds back the store write methods, but they are implemented to ensure consistency. For your usage you'd obtain the informer from the factory or with Informable.runnableInformer and add the state before calling run. |
Awesome, thanks. |
also allowing for indexers to be added/removed at runtime, and exposing Store.getKey
also allowing for indexers to be added/removed at runtime, and exposing Store.getKey
Describe the bug
I am updating the kubernetes client in my application from 5.4.1 to the latest 5.12.1. And the API changed, I cannot write in the store of the informer anymore. The workaround I have is to explicietly cast the Store instance into a Cache, to be able to use the add function.
My use case is that we have an external database where is stored all the history of the statuses of the pods launched by Argo. To be sure that we don't miss any status update, we use the informer pattern. And in case of error where our application is not up, but pods are deleted during that time, before starting the informer we prepopulate the cache with the last known list of running pods. This way, at startup we get notified of any missed deletion. This pattern was found described in this exemple in the go client:
https://github.com/kubernetes/client-go/blob/2f52a105e63e9ac7affb1a0f533c62883611ba81/examples/workqueue/main.go#L202
Looking at the history of the fabric8 client, I see that the APIs have been removed by #3091
Fabric8 Kubernetes Client version
other (please specify in additional context)
Steps to reproduce
Use the Store API.
Expected behavior
A writable Store API, like the go client has.
Runtime
Kubernetes (vanilla)
Kubernetes API Server version
1.21.6
Environment
other (please specify in additional context)
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: