-
-
Notifications
You must be signed in to change notification settings - Fork 776
Fix a bug with trigger payload validation in linux.FileWatchSensor sensor #4491
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
Conversation
1. Mitigate / avoid race when calling add_file() before tailer has been initialized 2. Fix a bug with failing to dispatch a trigger due to code using invalid trigger type reference (it uses trigger ref instead of trigger type ref)
reference and not trigger type reference is passed to it.
This reverts commit 22bb9a0.
| raise Exception('Trigger %s did not contain a ref.' % trigger) | ||
|
|
||
| # Wait a bit to avoid initialization race in logshipper library | ||
| eventlet.sleep(1.0) |
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.
There is an edge case in logshipper library.
If a trigger is added and add_file is called before the tailer is initialized, an exception will be thrown and the sensor will die / crash (this can happen because add_trigger method is called asynchronously and it could be called before run() and tailer fully initialized).
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.
:(
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.
Yeah, it's not ideal.
I could make it 100% deterministic by shuffling around the code (set initialized or similar variable to True inside run() and only proceed inside add_handler when that variable is True).
I think that's too complicated though since sleep seems to work just as fine (and it's one line of code).
It also only affects a single sensor right now so there is no point in handling that inside sensor container / base sensor class code.
| raise Exception('Trigger %s did not contain a ref.' % trigger) | ||
|
|
||
| # Wait a bit to avoid initialization race in logshipper library | ||
| eventlet.sleep(1.0) |
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.
:(
This pull request fixes an issue with file watch sensor not working correctly since the trigger payload validation has been enabled by default a couple of releases ago.
The root cause was that
validate_trigger_payload()method only worked with TriggerType reference, but not with Trigger reference.FileWatch sensor is a bit special since it's the only sensor which works with actual triggers and not trigger types (aka issue didn't affect other sensors).
Resolves #4486
TODO