-
Notifications
You must be signed in to change notification settings - Fork 218
fix: cover informer automatic start case #662
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
deaff91
fix: cover informer automatic start case
csviri e053497
fix: formatting
csviri 43e3d8c
fix: event handler volatile
csviri 2a08236
refactor: rename private field
csviri b8ed31e
feature: log warning if passing an already runnning informer
csviri b2183ed
fix: formatting
csviri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this need some sort of protection as there may be a race conditions between the event being fired and the
eventHandler
being set in theAbstractEventSource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally it is
LifecycleAware
, and we "run
" the informer only onstart
. But there are some cases where the informer is run automtically when created in fabric8 client "Informable
" way, (what we want, like it is passed as a param). Will address this in an issue for fabric8 client.For now this is an ugly workaround :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but my understanding is that
propagateEvent
may run as per the invocation of the constructor so while thepropagateEvent
in invoked by an informer thread another thread my set theeventHandler
.Since the
eventHandler
is neither volatile nor protected by a lock then the two thread my see a different value foreventHandler
, right ? Also, since there is a list of events, some events may get propagated and some other not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, good point, changed it to
volatile
.But I don't understand the second point:
All the events are propagated from a list from one thread, so it's either sees the variable set or not, or?
Or the thread can see the actual reference from certain point of time...? This is what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming that
esourceToUIDs.apply(object)
produces 3 elements, and theeventHandler
is set once theuids.forEach
is processing the 2nd element, then the 3rd UID will trigger a reconcile, the first two don't.It may be ok but I don't know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is with volatile (now set, thx) and
LifecycleAware
all should be covered, if the Informer is created and did not run. Now it can happen that if created in a certain way Informer.run method called automatically in fabric8 - will address this in fabric8 client and a subsequent issue here.For now this workaround should mitigate this issues, there can be missed events on startup, but since this is event source and not a the main custom resource event source, it's not that big deal IMHO. Hopefully we can address this before we release v2. But actually will be just a docs from our side to not create an Informer event source when set as paramter. (Or check if the passed event source is running, in case yes log a warning)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it's doable this way:
7eb3aa7
Added warn log message if user passes a running informer.