diff --git a/agent-control/agent-type-registry/newrelic/com.newrelic.infrastructure-0.1.0.yaml b/agent-control/agent-type-registry/newrelic/com.newrelic.infrastructure-0.1.0.yaml index 7ad8f59492..735c05ebfd 100644 --- a/agent-control/agent-type-registry/newrelic/com.newrelic.infrastructure-0.1.0.yaml +++ b/agent-control/agent-type-registry/newrelic/com.newrelic.infrastructure-0.1.0.yaml @@ -80,6 +80,27 @@ variables: type: number required: false default: 18003 + oci: + registry: + description: "Package registry url" + type: string + required: false + default: docker.io + variants: + ac_config_field: "oci_registry_urls" + values: [ "docker.io" ] + repository: + description: "Package repository name" + type: string + required: false + default: newrelic/infrastructure-agent-artifacts + variants: + ac_config_field: "oci_repository_urls" + values: [ "newrelic/infrastructure-agent-artifacts" ] + version: + description: "Agent version" + type: string + required: true k8s: # HelmChart based sub agents should always have `chart_values`. chart_values: @@ -197,11 +218,13 @@ deployment: NRIA_LOG_ROTATE_MAX_FILES: "5" NRIA_CUSTOM_PLUGIN_INSTALLATION_DIR: "${nr-sub:packages.infra-agent.dir}\\integrations" NRIA_SAFE_BIN_DIR: "${nr-sub:packages.infra-agent.dir}\\integrations" + # Config folders where integrations and logging configs parsed from local/remote values are stored and looked for. NRIA_PLUGIN_DIR: "${nr-sub:filesystem_agent_dir}\\integrations.d" NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:filesystem_agent_dir}\\logging.d" - NRIA_FLUENT_BIT_EXE_PATH: "${nr-sub:packages.infra-agent.dir}\\logging\\fluent-bit.exe" - NRIA_FLUENT_BIT_PARSERS_PATH: "${nr-sub:packages.infra-agent.dir}\\logging\\parsers.conf" - NRIA_FLUENT_BIT_NR_LIB_PATH: "${nr-sub:packages.infra-agent.dir}\\logging\\out_newrelic.dll" + # Where fluent-bit exe is installed + NRIA_LOGGING_BIN_DIR: "${nr-sub:packages.infra-agent.dir}\\logging" + # Where parsers.conf and out_newrelic.so are placed and fb.db will be created + NRIA_LOGGING_HOME_DIR: "${nr-sub:packages.infra-agent.dir}\\logging" NRIA_STATUS_SERVER_ENABLED: true NRIA_STATUS_SERVER_PORT: "${nr-var:health_port}" NR_HOST_ID: "${nr-ac:host_id}" @@ -218,6 +241,14 @@ deployment: http: path: "/v1/status/health" port: ${nr-var:health_port} + packages: + infra-agent: + type: tar + download: + oci: + registry: ${nr-var:oci.registry} + repository: ${nr-var:oci.repository} + version: ${nr-var:version} version: path: /usr/bin/newrelic-infra args: @@ -231,13 +262,24 @@ deployment: logging.d: ${nr-var:config_logging} executables: - id: newrelic-infra - path: /usr/bin/newrelic-infra + path: ${nr-sub:packages.infra-agent.dir}/newrelic-infra args: - --config - ${nr-sub:filesystem_agent_dir}/config/newrelic-infra.yaml env: + # NRIA_AGENT_DIR is needed in order to change the root directory for the agent data on Linux. + # This is useful to make sure that all the data generated by the agent is stored inside the AC managed filesystem directory. + # Otherwise, a user could write data to a folder with lower permissions and potentially escalate privileges. + # For the same reason we are also changing the location of the integration binaries. + NRIA_AGENT_DIR: "${nr-sub:filesystem_agent_dir}/newrelic-infra" + NRIA_CUSTOM_PLUGIN_INSTALLATION_DIR: "${nr-sub:packages.infra-agent.dir}/integrations" + NRIA_SAFE_BIN_DIR: "${nr-sub:packages.infra-agent.dir}/integrations" + # Config folders where integrations and logging configs parsed from local/remote values are stored and looked for. NRIA_PLUGIN_DIR: "${nr-sub:filesystem_agent_dir}/integrations.d" NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:filesystem_agent_dir}/logging.d" + # Where parsers.conf and out_newrelic.so are placed and fb.db will be created + NRIA_LOGGING_HOME_DIR: "${nr-sub:packages.infra-agent.dir}/logging" + # NRIA_LOGGING_BIN_DIR is not added because it continues being installed with apt, yum, zypp in its current location. NRIA_STATUS_SERVER_ENABLED: true NRIA_STATUS_SERVER_PORT: "${nr-var:health_port}" NR_HOST_ID: "${nr-ac:host_id}" diff --git a/agent-control/src/agent_type/definition/agent_type_validation_tests.rs b/agent-control/src/agent_type/definition/agent_type_validation_tests.rs index 29e083d55e..d9a947f6c4 100644 --- a/agent-control/src/agent_type/definition/agent_type_validation_tests.rs +++ b/agent-control/src/agent_type/definition/agent_type_validation_tests.rs @@ -214,10 +214,11 @@ static AGENT_TYPE_INFRASTRUCTURE: LazyLock = .into(), values_linux: AgentTypeValues { cases: HashMap::from([ - ("mandatory fields only", ""), + ("mandatory fields only", r#"version: "some-version""#), ( "check all value types are correct", r#" + version: "some-version" config_agent: "some file contents" config_integrations: map_string: "some file contents" @@ -414,10 +415,11 @@ static AGENT_TYPE_OTEL_COLLECTOR: LazyLock = .into(), values_linux: AgentTypeValues { cases: HashMap::from([ - ("mandatory fields only", ""), + ("mandatory fields only", r#"version: "some-version""#), ( "check all value types are correct", r#" + version: "some-version" config: "some file contents" backoff_delay: "10s" health_check.path: "/health" @@ -478,6 +480,7 @@ static AGENT_TYPE_OTEL_COLLECTOR_OLD: LazyLock = ( "check all value types are correct", r#" + version: "some-version" config: "some file contents" backoff_delay: "10s" health_check.path: "/health" diff --git a/test/ac-ansible-roles/install_ac_recipe/tasks/debian.yaml b/test/ac-ansible-roles/install_ac_recipe/tasks/debian.yaml index 7a20482e43..0b4b0eb29b 100644 --- a/test/ac-ansible-roles/install_ac_recipe/tasks/debian.yaml +++ b/test/ac-ansible-roles/install_ac_recipe/tasks/debian.yaml @@ -51,7 +51,6 @@ NEW_RELIC_AUTH_PRIVATE_KEY_PATH={{ agent_control_private_key }} \ NEW_RELIC_AGENT_VERSION={{ agent_control_version }} \ NEW_RELIC_REGION={{ nr_region }} \ - NEW_RELIC_AGENT_CONTROL_HOST_MONITORING_SOURCE={{ monitoring_source }} \ NR_CLI_FLEET_ID={{ fleet_id }} \ NEW_RELIC_AGENT_CONTROL_FLEET_ENABLED={{ fleet_enabled }} \ NR_AC_MIGRATE_INFRA_CONFIG={{ migrate_infra_config }} \ diff --git a/test/ac-ansible-roles/install_ac_recipe/vars/main.yaml b/test/ac-ansible-roles/install_ac_recipe/vars/main.yaml index 227b98962a..03ab4a7479 100644 --- a/test/ac-ansible-roles/install_ac_recipe/vars/main.yaml +++ b/test/ac-ansible-roles/install_ac_recipe/vars/main.yaml @@ -2,9 +2,6 @@ # List of recipes to be installed recipe_list: "agent-control" -# Source of monitoring configuration ("infra-agent", "otel") -monitoring_source: "none" - # Unique identifier for the fleet this agent belongs to fleet_id: "" diff --git a/test/e2e-runner/src/linux/scenarios.rs b/test/e2e-runner/src/linux/scenarios.rs index 55c3a07b01..eda6d26ee4 100644 --- a/test/e2e-runner/src/linux/scenarios.rs +++ b/test/e2e-runner/src/linux/scenarios.rs @@ -3,3 +3,6 @@ pub mod infra_agent; pub mod nrdot_agent; pub mod proxy; pub mod remote_config; + +// TODO we should get the version dynamically from the recipe itself +const INFRA_AGENT_VERSION: &str = "1.72.1"; diff --git a/test/e2e-runner/src/linux/scenarios/ebpf_agent.rs b/test/e2e-runner/src/linux/scenarios/ebpf_agent.rs index c70031cd70..3ace9bddfb 100644 --- a/test/e2e-runner/src/linux/scenarios/ebpf_agent.rs +++ b/test/e2e-runner/src/linux/scenarios/ebpf_agent.rs @@ -3,6 +3,7 @@ use crate::common::RecipeData; use crate::common::config::write_agent_local_config; use crate::common::on_drop::CleanUp; use crate::common::test::retry_panic; +use crate::linux::scenarios::INFRA_AGENT_VERSION; use crate::{ common::{config, nrql}, linux::{ @@ -57,11 +58,13 @@ config_agent: // Infra agent config: it is used to generate traffic for eBPF metrics to appear write_agent_local_config( &linux::local_config_path("nr-infra"), - String::from( + format!( r#" config_agent: - license_key: '{{NEW_RELIC_LICENSE_KEY}}' - "#, + license_key: '{{{{NEW_RELIC_LICENSE_KEY}}}}' +version: {} +"#, + INFRA_AGENT_VERSION ), ); diff --git a/test/e2e-runner/src/linux/scenarios/infra_agent.rs b/test/e2e-runner/src/linux/scenarios/infra_agent.rs index 8eacc8c4ba..1d3c4abf54 100644 --- a/test/e2e-runner/src/linux/scenarios/infra_agent.rs +++ b/test/e2e-runner/src/linux/scenarios/infra_agent.rs @@ -1,9 +1,10 @@ -use crate::common::config::write_agent_local_config; +use crate::common::config::{ac_debug_logging_config, update_config, write_agent_local_config}; use crate::common::on_drop::CleanUp; use crate::common::test::retry_panic; use crate::common::{Args, RecipeData}; +use crate::linux::scenarios::INFRA_AGENT_VERSION; use crate::{ - common::{config, nrql}, + common::nrql, linux::{ self, install::{install_agent_control_from_recipe, tear_down_test}, @@ -28,37 +29,62 @@ pub fn test_installation_with_infra_agent(args: Args) { chrono::Local::now().format("%Y-%m-%d_%H-%M-%S") ); + let infra_agent_id: &str = "nr-infra"; + info!("Setup Agent Control config"); - let debug_log_config = config::ac_debug_logging_config(linux::DEFAULT_LOG_PATH); - let config = format!( - r#" + let debug_log_config = ac_debug_logging_config(linux::DEFAULT_LOG_PATH); + update_config( + linux::DEFAULT_AC_CONFIG_PATH, + format!( + r#" host_id: {test_id} agents: nr-infra: agent_type: "newrelic/com.newrelic.infrastructure:0.1.0" {debug_log_config} "# + ), ); - config::update_config(linux::DEFAULT_AC_CONFIG_PATH, config); write_agent_local_config( - &linux::local_config_path("nr-infra"), - String::from( + &linux::local_config_path(infra_agent_id), + format!( r#" config_agent: - status_server_enabled: true - status_server_port: 18003 - license_key: '{{NEW_RELIC_LICENSE_KEY}}' - "#, + license_key: '{{{{NEW_RELIC_LICENSE_KEY}}}}' + log: + level: debug +config_logging: + logging.yml: + logs: + - name: syslog + file: /var/log/syslog + attributes: + host.id: {test_id} +version: {} +"#, + INFRA_AGENT_VERSION ), ); linux::service::restart_service(linux::SERVICE_NAME); let nrql_query = format!(r#"SELECT * FROM SystemSample WHERE `host.id` = '{test_id}' LIMIT 1"#); - info!(nrql = nrql_query, "Checking results of NRQL"); + info!( + nrql = nrql_query, + "Checking results of NRQL to check SystemSample" + ); let retries = 60; retry_panic(retries, Duration::from_secs(10), "nrql assertion", || { nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query) }); + + let nrql_query = format!(r#"SELECT * FROM Log WHERE `host.id` = '{test_id}' LIMIT 1"#); + info!(nrql = nrql_query, "Checking results of NRQL to check logs"); + let retries = 30; + retry_panic(retries, Duration::from_secs(10), "nrql assertion", || { + nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query) + }); + + info!("Test completed successfully"); } diff --git a/test/e2e-runner/src/linux/scenarios/proxy.rs b/test/e2e-runner/src/linux/scenarios/proxy.rs index 3349d7f057..b0d5d83179 100644 --- a/test/e2e-runner/src/linux/scenarios/proxy.rs +++ b/test/e2e-runner/src/linux/scenarios/proxy.rs @@ -3,6 +3,7 @@ use crate::common::on_drop::CleanUp; use crate::common::test::retry_panic; use crate::common::{Args, RecipeData}; use crate::linux::install::tear_down_test; +use crate::linux::scenarios::INFRA_AGENT_VERSION; use crate::{ common::{config, nrql}, linux::{self, bash::exec_bash_command, install::install_agent_control_from_recipe}, @@ -77,7 +78,9 @@ config_agent: level: debug proxy: {PROXY_URL} license_key: '{{{{NEW_RELIC_LICENSE_KEY}}}}' -"# +version: {} +"#, + INFRA_AGENT_VERSION ), ); diff --git a/test/e2e-runner/src/linux/scenarios/remote_config.rs b/test/e2e-runner/src/linux/scenarios/remote_config.rs index d6f6f5fbf9..88f078f517 100644 --- a/test/e2e-runner/src/linux/scenarios/remote_config.rs +++ b/test/e2e-runner/src/linux/scenarios/remote_config.rs @@ -2,6 +2,7 @@ use crate::common::on_drop::CleanUp; use crate::common::test::retry_panic; use crate::common::{Args, RecipeData}; use crate::linux::install::tear_down_test; +use crate::linux::scenarios::INFRA_AGENT_VERSION; use crate::{ common::{config, nrql}, linux::{self, install::install_agent_control_from_recipe}, @@ -41,16 +42,19 @@ pub fn test_remote_config_is_applied(args: Args) { info!("Setup infra-agent config"); config::write_agent_local_config( &linux::local_config_path("nr-infra"), - r#" + format!( + r#" config_agent: status_server_enabled: true status_server_port: 18003 - license_key: {{NEW_RELIC_LICENSE_KEY}} + license_key: {{{{NEW_RELIC_LICENSE_KEY}}}} custom_attributes: config_origin: local - test_id: {{TEST_ID}} -"# - .to_string(), + test_id: {{{{TEST_ID}}}} +version: {} +"#, + INFRA_AGENT_VERSION + ), ); linux::service::restart_service(linux::SERVICE_NAME); diff --git a/test/onhost-canaries/ansible/install_ac_with_basic_config.yml b/test/onhost-canaries/ansible/install_ac_with_basic_config.yml index fb33bec077..475ce24191 100644 --- a/test/onhost-canaries/ansible/install_ac_with_basic_config.yml +++ b/test/onhost-canaries/ansible/install_ac_with_basic_config.yml @@ -25,6 +25,10 @@ include_role: name: caos.ansible_roles.hostname + - name: Set infra version matching an existing one in the Github oci package repo + ansible.builtin.set_fact: + infra_version: "1.72.1" + - name: Install Agent Control vars: repo_endpoint: "{{ repo_endpoint }}" @@ -93,6 +97,7 @@ status_server_enabled: true status_server_port: 18003 license_key: '{{NEW_RELIC_LICENSE_KEY}}' + version: {% endraw -%} {{ infra_version }} {%- raw %} {% endraw %} - name: Env file @@ -108,9 +113,9 @@ service_name: "newrelic-agent-control" action: "restart" - - name: Wait for Infra Agent to start + - name: Wait for Infra Agent to start and download infra-agent pause: - seconds: 30 + seconds: 60 - name: Assert Agent Control and Infra Agent are running include_role: