Skip to content
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] enabling service discovery via named pipe. #113

Merged
merged 8 commits into from
Dec 2, 2016

Conversation

truthbk
Copy link
Member

@truthbk truthbk commented Nov 9, 2016

What does this PR do?

Enables service discovery for JMXfetch.

Once a service discovery config is detected by the agent it will be pushed as YAML via a named pipe: dd-service_discovery that lives in /tmp by default.

If multiple changes are detected, these will be submitted to JMXfetch in a single write operation to avoid race conditions. The pipe should take care of locking from the reading and writing ends, so we can guarantee all configs will be read on the JMXfetch in a single iteration and thus help avoid having multiple versions of the same config in the pipe at any given time. We will then do the chopping up of the various configurations read with a simple String.split(SD_CONFIGURATION_SEPARATOR) operaion.

Motivation

Enabling Service Discovery for JMXfetch integrations.

Testing Guidelines

An overview on testing
is available in our contribution guidelines.

Additional Notes

Related PR: DataDog/dd-agent#3010

[service_discovery] fixing configuration.

[service_discovery] store SD configs in its own cache.

[service_discovery] use named pipes to receive service discovery configs.

[service_discovery] parsing pipe input into config.

[service_discovery] move relevant options to AppConfig.

[service_discovery] fixing up service discovery config traversal.

[service_discovery] only remove config from list if not a service discovery received config.

[logging] prettify logging statement.
Copy link
Member

@hkaj hkaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some minor comments, also 2 things to consider:

  • this should probably come with a test or two
  • /tmp is a risky choice, sometimes the agent doesn't have access to it. I guess we can keep it and if failures are reported switch to /opt/datadog-agent/run with a fallback to /tmp if it doesn't exit.

@@ -19,6 +29,9 @@
import org.apache.log4j.Appender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure some of these aren't used anywhere, you should open the project in eclipse and let it clean them up for you

int len = sd_pipe.available();
byte[] buffer = new byte[len];
sd_pipe.read(buffer);
reinit.set(process_service_discovery(buffer));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should either use setReinit or remove it

@hkaj
Copy link
Member

hkaj commented Nov 21, 2016

Tests failed on a certificate issue on maven's repos, re-triggered them. Once they pass, SHIPIT.

@truthbk
Copy link
Member Author

truthbk commented Dec 2, 2016

No changes to the logic. Just added a couple simple tests. We're green, so merging!

@truthbk truthbk merged commit c93a024 into master Dec 2, 2016
@truthbk truthbk deleted the jaime/pipedsd branch December 2, 2016 19:30
@olivielpeau olivielpeau added this to the 0.13.0 milestone Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants