djoos-cookbooks / newrelic

Development repository for the newrelic cookbook
https://supermarket.chef.io/cookbooks/newrelic
MIT License
143 stars 247 forks source link

Recipe newrelic::java_agent fails install with the `Error executing action run on resource execute[newrelic_install_newrelic.jar]` #384

Closed abhishekops closed 4 years ago

abhishekops commented 4 years ago

newrelic::default recipe run was successful. Issues seen during the run of newrelic::java_agent recipe

cookbook 'newrelic', '= 2.40.3' (Tried with 2.35.0, 2.25.0 and versions before infra agent was included, error seems to be consistent across versions.) chef_version=13.12.14 JAVA is installed and path is set. (AdoptOpenJDK 11)

Below is the attributes that are being passed.

"newrelic": {
      "license": "xxxxxx",
      "java_agent": {
        "install_dir": "/opt/newrelic"
      },
      "application_monitoring": {
        "app_name": "xxxxxxx"
      }
    },

TRACE follows:

[execute] Error parsing arguments New Relic Agent Version 5.10.0 usage: java -jar newrelic.jar -h Prints help -v Prints the agent version -version Prints the agent version

             Commands:
             instrument    [OPTIONS]                Validates a custom instrumentation
             xml configuration file.
             deployment    [OPTIONS] [description]  Records a deployment

   ================================================================================
   Error executing action `run` on resource 'execute[newrelic_install_newrelic.jar]'
   ================================================================================

   Mixlib::ShellOut::ShellCommandFailed
   ------------------------------------
   Expected process to exit with [0], but received '1'
   ---- Begin output of sudo java -jar newrelic.jar -s /opt/newrelic install ----
   STDOUT: New Relic Agent Version 5.10.0
   usage: java -jar newrelic.jar
    -h         Prints help
    -v         Prints the agent version
    -version   Prints the agent version

   Commands:
   instrument    [OPTIONS]                Validates a custom instrumentation
   xml configuration file.
   deployment    [OPTIONS] [description]  Records a deployment
   STDERR: Error parsing arguments
   ---- End output of sudo java -jar newrelic.jar -s /opt/newrelic install ----
   Ran sudo java -jar newrelic.jar -s /opt/newrelic install returned 1

   Resource Declaration:
   ---------------------
   # In /tmp/packer-chef-client/local-mode-cache/cache/cookbooks/newrelic/providers/agent_java.rb

   108:   execute "newrelic_install_#{jar_file}" do
   109:     cwd new_resource.install_dir
   110:     command "sudo java -jar newrelic.jar -s #{app_location} #{new_resource.agent_action}"
   111:     only_if { new_resource.execute_agent_action == true }
   112:   end
   113: end

   Compiled Resource:
   ------------------
   # Declared in /tmp/packer-chef-client/local-mode-cache/cache/cookbooks/newrelic/providers/agent_java.rb:108:in `install_newrelic'

   execute("newrelic_install_newrelic.jar") do
     action [:run]
     default_guard_interpreter :execute
     command "sudo java -jar newrelic.jar -s /opt/newrelic install"
     backup 5
     cwd "/opt/newrelic"
     returns 0
     user nil
     declared_type :execute
     cookbook_name "newrelic"
     domain nil
     only_if { #code block }
   end

   System Info:
   ------------
   chef_version=13.12.14
   platform=centos
   platform_version=7.7.1908
   ruby=ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
   program_name=chef-client worker: ppid=2164;start=07:49:13;
   executable=/opt/chef/bin/chef-client

[2020-03-05T07:52:10+00:00] INFO: Running queued delayed notifications before re-raising exception

 ================================================================================
 Error executing action `install` on resource 'newrelic_agent_java[Install]'
 ================================================================================

 Mixlib::ShellOut::ShellCommandFailed
 ------------------------------------
 execute[newrelic_install_newrelic.jar] (/tmp/packer-chef-client/local-mode-cache/cache/cookbooks/newrelic/providers/agent_java.rb line 108) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
 ---- Begin output of sudo java -jar newrelic.jar -s /opt/newrelic install ----
 STDOUT: New Relic Agent Version 5.10.0
 usage: java -jar newrelic.jar
  -h         Prints help
  -v         Prints the agent version
  -version   Prints the agent version

 Commands:
 instrument    [OPTIONS]                Validates a custom instrumentation
 xml configuration file.
 deployment    [OPTIONS] [description]  Records a deployment
 STDERR: Error parsing arguments
 ---- End output of sudo java -jar newrelic.jar -s /opt/newrelic install ----
 Ran sudo java -jar newrelic.jar -s /opt/newrelic install returned 1

 Resource Declaration:
 ---------------------
 # In /tmp/packer-chef-client/local-mode-cache/cache/cookbooks/newrelic/recipes/java_agent.rb

   8: newrelic_agent_java 'Install' do
   9:   license lazy { NewRelic.application_monitoring_license(node) }
  10:   version node['newrelic']['java_agent']['version'] unless node['newrelic']['java_agent']['version'].nil?
  11:   install_dir node['newrelic']['java_agent']['install_dir'] unless node['newrelic']['java_agent']['install_dir'].nil?
  12:   repository node['newrelic']['java_agent']['repository'] unless node['newrelic']['java_agent']['repository'].nil?
  13:   app_location node['newrelic']['java_agent']['app_location'] unless node['newrelic']['java_agent']['app_location'].nil?
  14:   template_cookbook node['newrelic']['java_agent']['template_cookbook'] unless node['newrelic']['java_agent']['template_cookbook'].nil?
  15:   template_source node['newrelic']['java_agent']['template_source'] unless node['newrelic']['java_agent']['template_source'].nil?
  16:   enable_custom_tracing node['newrelic']['java_agent']['enable_custom_tracing'] unless node['newrelic']['java_agent']['enable_custom_tracing'].nil?
  17:   enabled node['newrelic']['application_monitoring']['enabled'] unless node['newrelic']['application_monitoring']['enabled'].nil?
  18:   app_name node['newrelic']['application_monitoring']['app_name'] unless node['newrelic']['application_monitoring']['app_name'].nil?
  19:   high_security NewRelic.to_boolean(node['newrelic']['application_monitoring']['high_security']) unless node['newrelic']['application_monitoring']['high_security'].nil?
  20:   app_user node['newrelic']['java_agent']['app_user'] unless node['newrelic']['java_agent']['app_user'].nil?
  21:   app_group node['newrelic']['java_agent']['app_group'] unless node['newrelic']['java_agent']['app_group'].nil?
  22:   logfile node['newrelic']['application_monitoring']['logfile'] unless node['newrelic']['application_monitoring']['logfile'].nil?
  23:   logfile_path node['newrelic']['application_monitoring']['logfile_path'] unless node['newrelic']['application_monitoring']['logfile_path'].nil?
  24:   loglevel node['newrelic']['application_monitoring']['loglevel'] unless node['newrelic']['application_monitoring']['loglevel'].nil?
  25:   audit_mode node['newrelic']['java_agent']['audit_mode'] unless node['newrelic']['java_agent']['audit_mode'].nil?
  26:   log_file_count node['newrelic']['java_agent']['log_file_count'] unless node['newrelic']['java_agent']['log_file_count'].nil?
  27:   log_limit_in_kbytes node['newrelic']['java_agent']['log_limit_in_kbytes'] unless node['newrelic']['java_agent']['log_limit_in_kbytes'].nil?
  28:   log_daily node['newrelic']['java_agent']['log_daily'] unless node['newrelic']['java_agent']['log_daily'].nil?
  29:   daemon_ssl NewRelic.to_boolean(node['newrelic']['application_monitoring']['daemon']['ssl']) unless node['newrelic']['application_monitoring']['daemon']['ssl'].nil?
  30:   daemon_proxy node['newrelic']['application_monitoring']['daemon']['proxy'] unless node['newrelic']['application_monitoring']['daemon']['proxy'].nil?
  31:   daemon_proxy_host node['newrelic']['application_monitoring']['daemon']['proxy_host'] unless node['newrelic']['application_monitoring']['daemon']['proxy_host'].nil?
  32:   daemon_proxy_port node['newrelic']['application_monitoring']['daemon']['proxy_port'] unless node['newrelic']['application_monitoring']['daemon']['proxy_port'].nil?
  33:   daemon_proxy_user node['newrelic']['application_monitoring']['daemon']['proxy_user'] unless node['newrelic']['application_monitoring']['daemon']['proxy_user'].nil?
  34:   daemon_proxy_password node['newrelic']['application_monitoring']['daemon']['proxy_password'] unless node['newrelic']['application_monitoring']['daemon']['proxy_password'].nil?
  35:   distributed_tracing_enable node['newrelic']['java_agent']['distributed_tracing_enable'] unless node['newrelic']['java_agent']['distributed_tracing_enable'].nil?
  36:   capture_params node['newrelic']['application_monitoring']['capture_params'] unless node['newrelic']['application_monitoring']['capture_params'].nil?
  37:   ignored_params node['newrelic']['application_monitoring']['ignored_params'] unless node['newrelic']['application_monitoring']['ignored_params'].nil?
  38:   transaction_tracer_enable node['newrelic']['application_monitoring']['transaction_tracer']['enable'] unless node['newrelic']['application_monitoring']['transaction_tracer']['enable'].nil?
  39:   transaction_tracer_threshold node['newrelic']['application_monitoring']['transaction_tracer']['threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['threshold'].nil?
  40:   transaction_tracer_record_sql node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'].nil?
  41:   transaction_tracer_stack_trace_threshold node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'].nil?
  42:   transaction_tracer_slow_sql node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'].nil?
  43:   transaction_tracer_explain_threshold node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'].nil?
  44:   error_collector_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['error_collector']['enable']) unless node['newrelic']['application_monitoring']['error_collector']['enable'].nil?
  45:   error_collector_ignore_errors node['newrelic']['application_monitoring']['error_collector']['ignore_errors'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_errors'].nil?
  46:   error_collector_ignore_classes node['newrelic']['application_monitoring']['error_collector']['ignore_classes'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_classes'].nil?
  47:   error_collector_ignore_status_codes node['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'].nil?
  48:   browser_monitoring_auto_instrument node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'] unless node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'].nil?
  49:   cross_application_tracer_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['cross_application_tracer']['enable']) unless node['newrelic']['application_monitoring']['cross_application_tracer']['enable'].nil?
  50:   thread_profiler_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['thread_profiler']['enable']) unless node['newrelic']['application_monitoring']['thread_profiler']['enable'].nil?
  51:   class_transformer_config node['newrelic']['java_agent']['class_transformer_config'] unless node['newrelic']['java_agent']['class_transformer_config'].empty?
  52:   labels node['newrelic']['application_monitoring']['labels'] unless node['newrelic']['application_monitoring']['labels'].nil?
  53:   trim_stats node['newrelic']['java_agent']['trim_stats'] unless node['newrelic']['java_agent']['trim_stats'].nil?
  54:   agent_action node['newrelic']['java_agent']['agent_action'] unless node['newrelic']['java_agent']['agent_action'].nil?
  55:   execute_agent_action node['newrelic']['java_agent']['execute_agent_action'] unless node['newrelic']['java_agent']['execute_agent_action'].nil?
  56: end

 Compiled Resource:
 ------------------
 # Declared in /tmp/packer-chef-client/local-mode-cache/cache/cookbooks/newrelic/recipes/java_agent.rb:8:in `from_file'

 newrelic_agent_java("Install") do
   action [:install]
   updated true
   updated_by_last_action true
   default_guard_interpreter :default
   declared_type :newrelic_agent_java
   cookbook_name "newrelic"
   recipe_name "java_agent"
   license "xxxxxx"
   version "latest"
   install_dir "/opt/newrelic"
   repository "https://download.newrelic.com/newrelic/java-agent/newrelic-agent"
   app_location "/opt/newrelic"
   enable_custom_tracing false
   app_name "xxxxxx"
   app_user "newrelic"
   app_group "newrelic"
   audit_mode false
   log_file_count 1
   log_limit_in_kbytes 0
   log_daily true
   trim_stats false
   agent_action "install"
   execute_agent_action true
 end

 System Info:
 ------------
 chef_version=13.12.14
 platform=centos
 platform_version=7.7.1908
 ruby=ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
 program_name=chef-client worker: ppid=2164;start=07:49:13;
 executable=/opt/chef/bin/chef-client

[2020-03-05T07:52:10+00:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers: [2020-03-05T07:52:10+00:00] ERROR: Running exception handlers Running handlers complete [2020-03-05T07:52:10+00:00] ERROR: Exception handlers complete Chef Client failed. 151 resources updated in 02 minutes 56 seconds [2020-03-05T07:52:10+00:00] FATAL: Stacktrace dumped to /tmp/packer-chef-client/local-mode-cache/cache/chef-stacktrace.out [2020-03-05T07:52:10+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2020-03-05T07:52:10+00:00] ERROR: newrelic_agent_java[Install] (newrelic::java_agent line 8) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[newrelic_install_newrelic.jar] (/tmp/packer-chef-client/local-mode-cache/cache/cookbooks/newrelic/providers/agent_java.rb line 108) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' ---- Begin output of sudo java -jar newrelic.jar -s /opt/newrelic install ---- STDOUT: New Relic Agent Version 5.10.0 usage: java -jar newrelic.jar -h Prints help -v Prints the agent version -version Prints the agent version

Commands: instrument [OPTIONS] Validates a custom instrumentation xml configuration file. deployment [OPTIONS] [description] Records a deployment STDERR: Error parsing arguments ---- End output of sudo java -jar newrelic.jar -s /opt/newrelic install ---- Ran sudo java -jar newrelic.jar -s /opt/newrelic install returned 1 [2020-03-05T07:52:10+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Please help.

abhishekops commented 4 years ago

Installation of Java 5.10.0 agent fails with the above trace.

But, I've made this to work with the following configuration, installation is successful. cookbook 'newrelic', '= 2.28.1', Java agent "version": "4.0.1" cookbook 'newrelic', '= 2.40.1', Java agent "version": "4.0.1"

But, the agent is not reporting any data to Newrelic. NR agent logs show the following error. warning: invalid connect response for app='Infrastructure'.

I also tried installing java agent version 3.32.0, which is our current setup in production, but it fails. I'm not sure if there is a dependency. I randomly picked up Java agent version "version": "4.0.1" and it worked.

abhishekops commented 4 years ago

I've solved the issue finally. I was supposed to add a flag to disable running the java agent, as I'm going through the injecting NR java agent route.

For anyone who is having the same problem. node['newrelic']['java_agent']['execute_agent_action'] - default is true(need to set to false)