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

Agent will not run on Linux if profiler log path contains non-existing intermediate paths #763

Closed
nr-ahemsath opened this issue Oct 19, 2021 · 1 comment · Fixed by #1051
Assignees
Labels
bug Something isn't working win != linux Behavior in windows is not the same as Linux and/or vice versa

Comments

@nr-ahemsath
Copy link
Member

nr-ahemsath commented Oct 19, 2021

Description

By default, the native profiler component of the agent logs to $NEW_RELIC_HOME/Logs (or $NEW_RELIC_HOME/logs on Linux). This location can be overridden with the environment variable NEWRELIC_PROFILER_LOG_DIRECTORY. On Windows, any non-existing components of the path supplied in this variable will be created (assuming the process being instrumented is running with sufficient permissions to do so). For example:

C:\existingDir <- exists
C:\existingDir\nonExistingDir <- doesn't exist
NEWRELIC_PROFILER_LOG_DIRECTORY=C:\existingDir\nonExistingDir\profilerLogs

then C:\existingDir\nonExistingDir will be created as part of the process of creating the profiler log directory.

On Linux, this doesn't work. Only the final component of the path can be automatically created.

NEWRELIC_PROFILER_LOG_DIRECTORY=/home/user/existingDir/profilerLogs <- works
NEWRELIC_PROFILER_LOG_DIRECTORY=/home/user/nonExistingDir/profilerLogs <- doesn't work

NOTE: this problem blocks the profiler from initializing, which means that the agent will not run.

The cause appears to be that on Windows, the system call used to create the profiler log directory is SHCreateDirectoryExW, which automatically creates intermediate path components: https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shcreatedirectoryexw

whereas on Linux, the system call used is mkdir, which doesn't: https://man7.org/linux/man-pages/man2/mkdir.2.html (under errors, see "ENOENT: A directory component in pathname does not exist")

Expected Behavior
The behavior of the agent should be consistent between Windows and Linux.

See this Stack Overflow discussion on how to make a version of mkdir that automatically creates intermediate path components: https://stackoverflow.com/questions/2336242/recursive-mkdir-system-call-on-unix

@nr-ahemsath nr-ahemsath added the bug Something isn't working label Oct 19, 2021
@nr-ahemsath nr-ahemsath changed the title Profiler log path will not automatically be created on Linux if any of the intermediate paths do not exist Agent will not run on Linux if profiler log path contains non-existing intermediate paths Oct 19, 2021
@nr-ahemsath nr-ahemsath added the win != linux Behavior in windows is not the same as Linux and/or vice versa label Nov 12, 2021
@angelatan2
Copy link
Contributor

Size = S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working win != linux Behavior in windows is not the same as Linux and/or vice versa
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants