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

Guard against agent config file schema validation errors preventing agent startup; unify framework/core behavior #835

Merged
merged 6 commits into from
Dec 13, 2021

Conversation

nr-ahemsath
Copy link
Member

@nr-ahemsath nr-ahemsath commented Dec 6, 2021

Description

A recent support ticket (NR internal-only link) had to do with an exception being thrown during newrelic.config schema validation. They were using the .NET Framework agent and were getting an error like this:

NewRelic  ERROR: [pid: 1748, tid: 10] There was an error initializing the agent: NewRelic.Agent.Core.Config.ConfigurationLoaderException: Unable to find the New Relic Agent configuration file C:\ProgramData\New Relic\.NET Agent\newrelic.config ---> System.IO.FileNotFoundException: Could not load file or assembly 'NewRelic.Agent.Core.resources, Version=9.0.0.0, Culture=en-US, PublicKeyToken=06552fced0b33d87' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'NewRelic.Agent.Core.resources' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'NewRelic.Agent.Core.resources' or one of its dependencies. The system cannot find the file specified.

The root cause of why this customer was having the problem was never found. However, in looking at the code for reading the config schema .xsd, we found that the framework agent and core agent had different behaviors: the framework agent was depending on reading the schema as an embedded resource from one of the agent's DLLs, whereas the core agent just read the file from disk. Since the newrelic.xsd file is present for both agents, we decided to just use the core agent behavior for both.

Additionally, and perhaps more importantly, we put exception handling around the schema validation so that any error in this process will not prevent agent startup.

Unit tests pass locally. Unit tests were refactored to no longer depend on the config schema being an embedded resource in the agent's core DLL, and the embedded resource was removed. Added a new unit test to cover the expected behavior if the config schema file is missing or empty.

I don't think we have or need any integration tests around this, nor is performance testing warranted. I also don't think a changelog entry is needed since this change should be completely transparent to users.

Reviewer Checklist

  • Perform code review
  • Pull request was adequately tested (new/existing tests, performance tests)
  • Review Changelog

@nr-ahemsath nr-ahemsath added the enhancement New feature or request label Dec 6, 2021
@nr-ahemsath nr-ahemsath changed the title For newrelic.config schema validation, use .xsd on disk for both agents Guard against agent config file schema validation errors preventing agent startup; unify framework/core behavior Dec 10, 2021
Copy link
Member

@jaffinito jaffinito left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@tehbio tehbio left a comment

Choose a reason for hiding this comment

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

Good change to unify a needless difference. 👍

@nr-ahemsath nr-ahemsath merged commit ecc0bb8 into main Dec 13, 2021
@nr-ahemsath nr-ahemsath deleted the fix-xsd-validation-exception branch January 14, 2022 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants