Skip to content

Add ability to specify directory that libasyncProfiler is exported to, to support /tmp partitions that have noexec set#1350

Merged
eyalkoren merged 6 commits intoelastic:masterfrom
marcjay:support-specifying-lib-directory-1226
Aug 20, 2020
Merged

Add ability to specify directory that libasyncProfiler is exported to, to support /tmp partitions that have noexec set#1350
eyalkoren merged 6 commits intoelastic:masterfrom
marcjay:support-specifying-lib-directory-1226

Conversation

@marcjay
Copy link
Contributor

@marcjay marcjay commented Aug 19, 2020

What does this PR do?

  • Adds elastic.apm.profiling_inferred_spans_lib_directory property that can be set to specify a directory which should be used to place the libasyncProfiler.so shared library, so that it can take a value such as /var/tmp when running in a server-hardened environment, without needing to change the java.io.tmpdir system property which would apply to the system being profiled as well. If not set, the java.io.tmpdir system property is used as before.
  • When loading the library, catch any UnsatisfiedLinkError errors, which would usually indicate a /tmp partition that has noexec set, and and re-throw the exception with a message to suggest setting the property
  • Add unit tests which cover this configurable behaviour
  • Update changelog and configuration docs

Fixes #1226

Checklist

  • This is an enhancement of existing features, or a new feature in existing plugins
    • I have updated CHANGELOG.asciidoc
    • I have added tests that prove my fix is effective or that my feature works
    • Added an API method or config option? Document in which version this will be introduced
    • I have made corresponding changes to the documentation
  • This is a bugfix
  • This is a new plugin
    • I have updated CHANGELOG.asciidoc
    • My code follows the style guidelines of this project
    • I have made corresponding changes to the documentation
    • I have added tests that prove my fix is effective or that my feature works
    • New and existing unit tests pass locally with my changes
    • I have updated supported-technologies.asciidoc
    • Added an API method or config option? Document in which version this will be introduced
    • Added an instrumentation plugin? Describe how you made sure that old, non-supported versions are not instrumented by accident.
  • This is something else
…, to support /tmp partitions that have noexec set

- Add elastic.apm.profiling_inferred_spans_lib_directory property that can be set to specify a directory which should be used to place the libasyncProfiler.so shared library, so that it can take a value such as /var/tmp when running in a server-hardened environment, without needing to change the `java.io.tmpdir` system property which would apply to the system being profiled as well. If not set, the `java.io.tmpdir` system property is used as before
- When loading the library, catch any UnsatisfiedLinkError errors, which would usually indicate a /tmp partition that has noexec set, and and re-throw the exception with a message to suggest setting the property
- Add unit tests which cover this configurable behaviour
- Update changelog and configuration docs

Fixes elastic#1226
@cla-checker-service
Copy link

cla-checker-service bot commented Aug 19, 2020

💚 CLA has been signed

@ghost
Copy link

ghost commented Aug 19, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Started by user eyalkoren, Replayed #10]

  • Start Time: 2020-08-20T13:31:23.440+0000

  • Duration: 46 min 2 sec

Test stats 🧪

Test Results
Failed 0
Passed 1459
Skipped 11
Total 1470

@marcjay marcjay force-pushed the support-specifying-lib-directory-1226 branch 2 times, most recently from d5a821d to 74f1c05 Compare August 19, 2020 19:43
Copy link
Member

@felixbarny felixbarny left a comment

Choose a reason for hiding this comment

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

It was really hard to find something to criticize 😄
Just some minor comments and suggestions
Great job and thanks for your contribution 👏

- Use backticks in documentation
- Remvove ProfilingConfiguration dependency in AsyncProfiler getInstance() method
- Add package-private reset method to reset AsyncProfiler singleton
- Use JUnit @tempdir to simplify temp directory creation in unit test
@marcjay
Copy link
Contributor Author

marcjay commented Aug 20, 2020

It was really hard to find something to criticize 😄
Just some minor comments and suggestions
Great job and thanks for your contribution 👏

Thanks for the speedy review and feedback! Plus the work that makes this an easy project to build/test/contribute to

Copy link
Contributor

@eyalkoren eyalkoren left a comment

Choose a reason for hiding this comment

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

Well done! 👏
Thanks @marcjay !

@eyalkoren eyalkoren merged commit 951b5ff into elastic:master Aug 20, 2020
@marcjay marcjay deleted the support-specifying-lib-directory-1226 branch August 20, 2020 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants