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

10.33.1 regression - Using run.sh on linux doesn't start agent due to home variable not set #2887

Closed
MerickOWA opened this issue Nov 15, 2024 · 2 comments · Fixed by #2888 or #2875
Closed
Labels
bug Something isn't working community To tag external issues and PRs

Comments

@MerickOWA
Copy link

MerickOWA commented Nov 15, 2024

Using run.sh to launch a dotnet application using 10.33.1 does not properly set CORECLR_NEW_RELIC_HOME (or the now deprecated CORECLR_NEWRELIC_HOME) variable, leading to the agent failing.

Description
I have a Docker container with the latest Debian package 10.33.1 of newrelic-dotnet-agent.

The entry point is set to ENTRYPOINT ["/usr/local/newrelic-dotnet-agent/run.sh", "dotnet", "Application.dll"]

The application starts up and runs, however the newrelic dotnet agent is no loaded and running. There are no log files in the /usr/local/newrelic-dotnet-agent/logs folder. Checking the dotnet /proc/7/maps file shows that libNewRelicProfiler.so is not loaded into memory anywhere.

Inspecting /proc/7/environ file of the dotnet process shows that there is no CORECLR_NEW_RELIC_HOME or CORECLR_NEWRELIC_HOME environment variable set. Instead there is a new/undocumented NRHOME variable set instead.

Expected Behavior
The application should launch successfully with proper new relic agent monitoring, with logs showing the agent is running in /usr/local/newrelic-dotnet-agent/logs

Steps to Reproduce

  1. run mkdir NewRelicBug
  2. run cd .\NewRelicBug
  3. run dotnet new webapp --no-https
  4. run dotnet build
  5. run
cat <<EOF > DockerFile
FROM mcr.microsoft.com/dotnet/aspnet:8.0
ADD https://download.newrelic.com/dot_net_agent/latest_release/newrelic-dotnet-agent_10.33.1_amd64.deb /tmp/newrelic-dotnet-agent.deb
RUN apt install /tmp/newrelic-dotnet-agent.deb
WORKDIR /app
COPY . .
ENTRYPOINT ["/usr/local/newrelic-dotnet-agent/run.sh", "dotnet", "NewRelicBug.dll"]
EOF
  1. docker build -f DockerFile ./bin/Debug/net8.0 -t bug
  2. docker run -d -name bug bug

Observe that running docker exec bug ls -l /usr/local/newrelic-dotnet-agent/logs returns total 0 indicating that there are no log files in the expected directory

Observe that running docker exec bug cat /proc/7/environ spits out a environment string which looks like the following which doesn't have a CORECLR_NEW_RELIC_HOME OR CORECLR_NEWRELIC_HOME environment variable set, instead it has a NRHOME environment variable instead.

NRHOME=/usr/local/newrelic-dotnet-agentCORECLR_ENABLE_PROFILING=1CORECLR_PROFILER_PATH=/usr/local/newrelic-dotnet-agent/libNewRelicProfiler.soCORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A}HOSTNAME=8952aec1a52cDOTNET_VERSION=8.0.11APP_UID=1654PWD=/appHOME=/rootASPNETCORE_HTTP_PORTS=8080SHLVL=1ASPNET_VERSION=8.0.11DOTNET_RUNNING_IN_CONTAINER=truePATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin_=/usr/bin/dotnet

Additionally, running docker exec bug cat /proc/7/maps spits how a long list of memory mapped files which doesn't include any references to libNewRelicProfiler.so or any of the dotnet assemblies in newrelic-dotnet-agent directory

Your Environment
Running WSL on Windows 10 w/ docker desktop 4.35.1
dotnet sdk 8.0.11
new relic agent 10.33.1

Additional context
To fix the issue, CORECLR_NEWRELIC_HOME or CORECLR_NEW_RELIC_HOME must be set manually in the DockerFile
7. run echo ENV CORECLR_NEWRELIC_HOME=/usr/local/newrelic-dotnet-agent >> DockerFile
8. run docker build -f DockerFile ./bin/Debug/net8.0 -t fixed
9. run docker run -d --name fixed fixed

Observe now that running docker exec fixed ls -l /usr/local/newrelic-dotnet-agent/logs

total 8
-rw-r--r-- 1 root root 2058 Nov 15 20:28 NewRelic.Profiler.8.log
-rw-r--r-- 1 root root  408 Nov 15 20:28 newrelic_agent_NewRelicBug.log

This seems to have been introduced by #2852 when build/Linux/build/common/run.sh was changed as follows
image

Since run.sh no longer sets CORECLR_NEWRELIC_HOME or CORECLR_NEW_RELIC_HOME, the agent can't start properly since AgentInstallConfiguration.cs is only looking for these two variables.

@MerickOWA MerickOWA added the bug Something isn't working label Nov 15, 2024
@workato-integration
Copy link

@tippmar-nr
Copy link
Member

@MerickOWA Thanks for your bug report.

We definitely made a mistake with the run.sh change in 10.33.1 - working on a fix now; will be deployed as 10.34.0 early next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community To tag external issues and PRs
Projects
None yet
2 participants