From 0aef51065e8ec689e86263d2bb03bcc8b188d87e Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 30 Dec 2024 13:02:19 -0800 Subject: [PATCH] updates and reverts --- lib/new_relic/agent/agent_helpers/startup.rb | 1 - lib/new_relic/agent/configuration/default_source.rb | 4 ++-- lib/new_relic/agent/health_check.rb | 10 +++++----- lib/new_relic/agent/new_relic_service.rb | 10 ++++++---- lib/new_relic/control/instance_methods.rb | 1 - test/new_relic/dependency_detection_test.rb | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/new_relic/agent/agent_helpers/startup.rb b/lib/new_relic/agent/agent_helpers/startup.rb index 5e62ffd525..bc1a98a57b 100644 --- a/lib/new_relic/agent/agent_helpers/startup.rb +++ b/lib/new_relic/agent/agent_helpers/startup.rb @@ -23,7 +23,6 @@ def already_started? def start return unless agent_should_start? - # early agent log_startup check_config_and_start_agent log_version_and_pid diff --git a/lib/new_relic/agent/configuration/default_source.rb b/lib/new_relic/agent/configuration/default_source.rb index b019651123..bb30d5f416 100644 --- a/lib/new_relic/agent/configuration/default_source.rb +++ b/lib/new_relic/agent/configuration/default_source.rb @@ -2189,14 +2189,14 @@ def self.notify }, # Agent Control :'agent_control.fleet_id' => { - :default => 'j2e4a6n0v1', # TODO: set default to nil before release + :default => nil, :public => true, :type => String, :allowed_from_server => false, :description => 'This assigns a fleet id to the language agent. This id is generated by agent control. If this setting is present, it indicates the agent is running in a super agent/fleet environment and health file(s) will be generated.' }, :'agent_control.health.delivery_location' => { - :default => 'health/', # TODO: set default to EMPTY_STRING before release + :default => NewRelic::Agent::EMPTY_STR, :public => true, :type => String, :allowed_from_server => false, diff --git a/lib/new_relic/agent/health_check.rb b/lib/new_relic/agent/health_check.rb index 7923570257..17a397d065 100644 --- a/lib/new_relic/agent/health_check.rb +++ b/lib/new_relic/agent/health_check.rb @@ -20,10 +20,10 @@ def initialize FORCED_DISCONNECT = {healthy: false, last_error: 'NR-APM-003', message: 'Forced disconnect received from New Relic (HTTP status code 410)'} HTTP_ERROR = {healthy: false, last_error: 'NR-APM-004', message: 'HTTP error response code [%s] recevied from New Relic while sending data type [%s]'} MISSING_APP_NAME = {healthy: false, last_error: 'NR-APM-005', message: 'Missing application name in agent configuration'} - # we don't raise an error when this happens at this time - APP_NAME_EXCEEDED = {healthy: false, last_error: 'NR-APM-006', message: 'The maximum number of configured app names (3) exceeded'} - # we don't raise an error when this happens at this time - PROXY_CONFIG_ERROR = {healthy: false, last_error: 'NR-APM-007', message: 'HTTP Proxy configuration error; response code [%s]'} + # we don't raise an error when this happens + # APP_NAME_EXCEEDED = {healthy: false, last_error: 'NR-APM-006', message: 'The maximum number of configured app names (3) exceeded'} + # we don't raise an error when this happens + # PROXY_CONFIG_ERROR = {healthy: false, last_error: 'NR-APM-007', message: 'HTTP Proxy configuration error; response code [%s]'} AGENT_DISABLED = {healthy: false, last_error: 'NR-APM-008', message: 'Agent is disabled via configuration'} FAILED_TO_CONNECT = {healthy: false, last_error: 'NR-APM-009', message: 'Failed to connect to New Relic data collector'} FAILED_TO_PARSE_CONFIG = {healthy: false, last_error: 'NR-APM-010', message: 'Agent config file is not able to be parsed'} @@ -48,7 +48,7 @@ def update_message(options) def create_and_run_health_check_loop return NewRelic::Agent.logger.debug('agent_control.fleet_id not found, skipping health checks') unless @fleet_id - return NewRelic::Agent.logger.debug('agent_control.health.file_destination not found, skipping health checks') unless @delivery_location + return NewRelic::Agent.logger.debug('agent_control.health.file_destination not found, skipping health checks') unless @delivery_location.empty? return NewRelic::Agent.logger.debug('agent_control.health.frequency zero or less, skipping health checks') unless @frequency > 0 NewRelic::Agent.record_metric('Supportability/AgentControl/Health/enabled', 1) diff --git a/lib/new_relic/agent/new_relic_service.rb b/lib/new_relic/agent/new_relic_service.rb index af5ea6fdde..ec99e98902 100644 --- a/lib/new_relic/agent/new_relic_service.rb +++ b/lib/new_relic/agent/new_relic_service.rb @@ -435,8 +435,6 @@ def relay_request(request, opts) attempts += 1 response = attempt_request(request, opts) rescue *CONNECTION_ERRORS => e - # TODO: HTTP CONNECTION ERRORS - # Seems that proxy errors would bubble up here close_shared_connection if attempts < MAX_ATTEMPTS ::NewRelic::Agent.logger.debug("Retrying request to #{opts[:collector]}#{filtered_uri(opts[:uri])} after #{e}") @@ -641,9 +639,13 @@ def check_post_size(post_string, endpoint) def send_request(opts) request = prep_request(opts) response = relay_request(request, opts) - return response if response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPAccepted) - handle_error_response(response, opts[:endpoint]) + if response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPAccepted) + NewRelic::Agent.agent.health_check.update_status(NewRelic::Agent::HealthCheck::HEALTHY) + response + else + handle_error_response(response, opts[:endpoint]) + end end def log_response(response) diff --git a/lib/new_relic/control/instance_methods.rb b/lib/new_relic/control/instance_methods.rb index da71bacd63..54ae7db34f 100644 --- a/lib/new_relic/control/instance_methods.rb +++ b/lib/new_relic/control/instance_methods.rb @@ -73,7 +73,6 @@ def init_plugin(options = {}) init_config(options) NewRelic::Agent.agent = NewRelic::Agent::Agent.instance - # start_health_loop init_instrumentation init_security_agent end diff --git a/test/new_relic/dependency_detection_test.rb b/test/new_relic/dependency_detection_test.rb index 0cdb34573a..d60a0cbadc 100644 --- a/test/new_relic/dependency_detection_test.rb +++ b/test/new_relic/dependency_detection_test.rb @@ -494,7 +494,7 @@ def test_already_executed_items_are_not_executed_again unexecuted.expect :executed, false unexecuted.expect :dependencies_satisfied?, true unexecuted.expect :disabled_configured?, false - unexecuted.expect :execute, -> { true } + unexecuted.expect :execute, -> { execution_took_place = true } executed = Minitest::Mock.new executed.expect :executed, true unexecuted.expect :disabled_configured?, false