Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}"
Expand All @@ -218,6 +241,14 @@ deployment:
http:
path: "/v1/status/health"
port: ${nr-var:health_port}
packages:
infra-agent:
type: tar
Copy link
Member

Choose a reason for hiding this comment

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

this is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why isn't it?
We do have it for windows.
type: zip

Copy link
Member

Choose a reason for hiding this comment

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

I believe that now we are taking such info from the package itself see https://github.com/newrelic/newrelic-agent-control/pulls

download:
oci:
registry: ${nr-var:oci.registry}
repository: ${nr-var:oci.repository}
version: ${nr-var:version}
version:
path: /usr/bin/newrelic-infra
args:
Expand All @@ -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"
Copy link
Member

Choose a reason for hiding this comment

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

@gsanchezgavier is this the variable that caused the leakage?

# 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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ static AGENT_TYPE_INFRASTRUCTURE: LazyLock<AgentTypeValuesTestCase> =
.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"
Expand Down Expand Up @@ -414,10 +415,11 @@ static AGENT_TYPE_OTEL_COLLECTOR: LazyLock<AgentTypeValuesTestCase> =
.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"
Expand Down Expand Up @@ -478,6 +480,7 @@ static AGENT_TYPE_OTEL_COLLECTOR_OLD: LazyLock<AgentTypeValuesTestCase> =
(
"check all value types are correct",
r#"
version: "some-version"
config: "some file contents"
backoff_delay: "10s"
health_check.path: "/health"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} \
Expand Down
3 changes: 0 additions & 3 deletions test/ac-ansible-roles/install_ac_recipe/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""

Expand Down
3 changes: 3 additions & 0 deletions test/e2e-runner/src/linux/scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
7 changes: 5 additions & 2 deletions test/e2e-runner/src/linux/scenarios/ebpf_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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}}'
"#,
version: {}
"#,
INFRA_AGENT_VERSION
),
);

Expand Down
52 changes: 39 additions & 13 deletions test/e2e-runner/src/linux/scenarios/infra_agent.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -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");
}
6 changes: 5 additions & 1 deletion test/e2e-runner/src/linux/scenarios/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -77,7 +78,10 @@ config_agent:
level: debug
proxy: {PROXY_URL}
license_key: '{{{{NEW_RELIC_LICENSE_KEY}}}}'
"#
test_id: {{{{TEST_ID}}}}
version: {}
"#,
INFRA_AGENT_VERSION
),
);

Expand Down
14 changes: 9 additions & 5 deletions test/e2e-runner/src/linux/scenarios/remote_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
Loading