-
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
refactoring informer logic for type safety and to refine the role of stores #3008
Conversation
also moves the responsibility for the lastResourceVersion to the DeltaFIFO - having it updatable outside the DeltaFIFO lock is dangerous this does not include the changes for fabric8io#2993 nor fabric8io#2995
Can one of the admins verify this patch? |
657dcb5
to
14f0fd9
Compare
SonarCloud Quality Gate failed. |
I'll rebase this after 5.3.1 - it appears that quite a few changes will make it into that release. And some of this is already being addressed by things like #3031 |
Hi @shawkins, 5.3.1 was just released |
@manusa thank you. I think the way forward will be to split this into several prs. I've started with #3048 - that incorporates some the changes from here. After that, can we look at #3029 Then I will include the changes that move the last resource version responsibility onto the store. Finally I'll open a pr that refines the Store interface. |
I'll now replace this pr with one that refines the store interface. This will be for after the deltafifo removal #3061 and ideally after a cleanup of the threading concerns for informers: shawkins#2 |
Description
While looking at changes for #2993, #2995, and another bug that has not been logged here. It appears there are some clarifications that could be made to improve the readability and the safety of the informer code. The central change is that Store should be more type specific and have a narrower interface - I realize this differs from the go implementation and this does change the public interface of SharedIndexInformer.getIndexer because the Store will no longer have replace, resync, or isPopulated. If it's a problem to make such a change it can of course be refined (previous code, all no-ops, or throw not implemented exceptions). In general it seems problematic that SharedIndexInformer.getIndexer returns as broad of an interface as it does - for example in DefaultSharedIndexInformer.addIndexers you can't add an indexer once running, but if you call SharedIndexInformer.getIndexer.addIndexers you can.
If you'd prefer another interface such as ResyncableStore vs direct usage of the DeltaFIFO in ResyncRunnable, Reflector, and ReflectorWatcher - that can be done as well, it just didn't seem needed given the single implementation of DeltaFIFO. I do see several implementations of Store types in go.
This also moves the responsibility for the lastResourceVersion to the DeltaFIFO - having it updatable outside the DeltaFIFO lock is dangerous. With the code pre #2812 it appears to allow for timing issues in threads updating the DeltaFIFO/lastResourceVersion:
The event generated from 2 will be an update showing s1 as the old state and s2 as the new
The event generated from 3 will be an update showing s2 as the old state and s1 as the new
A reconnect won't fix that as the last resourceVersion is s2.
In theory though on the next relist there will be a synchronization and event to s2 (or whatever the latest state is). However with the pre #2812 code any uncaught exception from relist will inhibit the job from running again.
Granted this should no longer happen after #2812 because the scheduled relist has been removed, but it is still something that should be guarded against.
@rohanKanojia or others let me know if you are open to these types of changes, I can refine this PR as needed.
Type of change
test, version modification, documentation, etc.)
Checklist