-
Notifications
You must be signed in to change notification settings - Fork 70
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
[service_discovery] Fix race condition preventing SD initialization #135
Conversation
If JMXFetch starts before the collector process creates the SD pipe, JMXFetch doesn't find the SD pipe and never re-tries opening it, (until it's fully restarted). To solve this, retry opening the SD pipe at every run iteration when SD is enabled. Also, add an `--sd-enabled` option to know whether JMXFetch should enable SD (i.e. whether it should expect the SD pipe to exist or not). The `--sd-standby` option is not used and has therefore been removed. This change requires a change to `dd-agent` to make `jmxfetch.py` pass the `--sd-enabled` option when SD-JMXFetch is enabled.
if(sdPipe == null && appConfig.getSDEnabled()) { | ||
// If SD is enabled and the pipe is not open, retry opening pipe | ||
sdPipe = newSdPipe(); | ||
} | ||
try { |
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.
Little nit, but could do
int len = 0
if(sdPipe != null && ((len = sdPipe.available()) > 0)) {
byte[] buffer....
No need to call sdPipe.available twice in succession.
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.
👍 , addressed in 1c5bede
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.
Nice one. My bad.
Addresses review comment
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.
Looks good to me
Thanks for fixing the var names to something more meaningful.
There's a weird Travis error for oraclejdk7, let's make sure we know what's up with that before merging. I think it's unrelated. |
Must've been a flaky test, I've just re-run the tests on oraclejdk7 and they're all green now! Merging |
If JMXFetch starts before the collector process creates the SD pipe,
JMXFetch doesn't find the SD pipe and never re-tries opening it (until
it's fully restarted).
To solve this, retry opening the SD pipe at every run iteration when
SD is enabled. Also, add an
--sd-enabled
option to know whetherJMXFetch should enable SD (i.e. whether it should expect the SD pipe
to exist or not).
The
--sd-standby
option is not used and has therefore been removed.This change requires a change to
dd-agent
to makejmxfetch.py
passthe
--sd-enabled
option when SD-JMXFetch is enabled. See DataDog/dd-agent#3306