Skip to content

Commit 1558de0

Browse files
committed
feat: linux nr_infra package download on agent_type
1 parent 11c65a4 commit 1558de0

File tree

3 files changed

+84
-14
lines changed

3 files changed

+84
-14
lines changed

agent-control/agent-type-registry/newrelic/com.newrelic.infrastructure-0.1.0.yaml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ variables:
8080
type: number
8181
required: false
8282
default: 18003
83+
oci:
84+
registry:
85+
description: "Package registry url"
86+
type: string
87+
required: false
88+
default: docker.io
89+
variants:
90+
ac_config_field: "oci_registry_urls"
91+
values: [ "docker.io" ]
92+
repository:
93+
description: "Package repository name"
94+
type: string
95+
required: false
96+
default: newrelic/infrastructure-agent-artifacts
97+
variants:
98+
ac_config_field: "oci_repository_urls"
99+
values: [ "newrelic/infrastructure-agent-artifacts" ]
100+
version:
101+
description: "Agent version"
102+
type: string
103+
required: true
83104
k8s:
84105
# HelmChart based sub agents should always have `chart_values`.
85106
chart_values:
@@ -197,6 +218,7 @@ deployment:
197218
NRIA_LOG_ROTATE_MAX_FILES: "5"
198219
NRIA_CUSTOM_PLUGIN_INSTALLATION_DIR: "${nr-sub:packages.infra-agent.dir}\\integrations"
199220
NRIA_SAFE_BIN_DIR: "${nr-sub:packages.infra-agent.dir}\\integrations"
221+
# Config folders where integrations and logging configs parsed from local/remote values are stored and looked for.
200222
NRIA_PLUGIN_DIR: "${nr-sub:filesystem_agent_dir}\\integrations.d"
201223
NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:filesystem_agent_dir}\\logging.d"
202224
NRIA_FLUENT_BIT_EXE_PATH: "${nr-sub:packages.infra-agent.dir}\\logging\\fluent-bit.exe"
@@ -218,6 +240,14 @@ deployment:
218240
http:
219241
path: "/v1/status/health"
220242
port: ${nr-var:health_port}
243+
packages:
244+
infra-agent:
245+
type: tar
246+
download:
247+
oci:
248+
registry: ${nr-var:oci.registry}
249+
repository: ${nr-var:oci.repository}
250+
version: ${nr-var:version}
221251
version:
222252
path: /usr/bin/newrelic-infra
223253
args:
@@ -231,13 +261,24 @@ deployment:
231261
logging.d: ${nr-var:config_logging}
232262
executables:
233263
- id: newrelic-infra
234-
path: /usr/bin/newrelic-infra
264+
path: ${nr-sub:packages.infra-agent.dir}/newrelic-infra
235265
args:
236266
- --config
237267
- ${nr-sub:filesystem_agent_dir}/config/newrelic-infra.yaml
238268
env:
269+
# NRIA_AGENT_DIR is needed in order to change the root directory for the agent data on Linux.
270+
# This is useful to make sure that all the data generated by the agent is stored inside the AC managed filesystem directory.
271+
# Otherwise, a user could write data to a folder with lower permissions and potentially escalate privileges.
272+
# For the same reason we are also changing the location of the integration binaries.
273+
NRIA_AGENT_DIR: "${nr-sub:filesystem_agent_dir}/newrelic-infra"
274+
NRIA_CUSTOM_PLUGIN_INSTALLATION_DIR: "${nr-sub:packages.infra-agent.dir}/integrations"
275+
NRIA_SAFE_BIN_DIR: "${nr-sub:packages.infra-agent.dir}/integrations"
276+
# Config folders where integrations and logging configs parsed from local/remote values are stored and looked for.
239277
NRIA_PLUGIN_DIR: "${nr-sub:filesystem_agent_dir}/integrations.d"
240278
NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:filesystem_agent_dir}/logging.d"
279+
NRIA_FLUENT_BIT_EXE_PATH: "${nr-sub:packages.infra-agent.dir}/logging/fluent-bit"
280+
NRIA_FLUENT_BIT_PARSERS_PATH: "${nr-sub:packages.infra-agent.dir}/logging/parsers.conf"
281+
NRIA_FLUENT_BIT_NR_LIB_PATH: "${nr-sub:packages.infra-agent.dir}/logging/out_newrelic.so"
241282
NRIA_STATUS_SERVER_ENABLED: true
242283
NRIA_STATUS_SERVER_PORT: "${nr-var:health_port}"
243284
NR_HOST_ID: "${nr-ac:host_id}"

test/e2e-runner/src/linux/scenarios.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ pub mod infra_agent;
33
pub mod nrdot_agent;
44
pub mod proxy;
55
pub mod remote_config;
6+
7+
// TODO we should get the version dynamically from the recipe itself
8+
const INFRA_AGENT_VERSION: &str = "1.72.1";

test/e2e-runner/src/linux/scenarios/infra_agent.rs

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use crate::common::config::write_agent_local_config;
1+
use crate::common::config::{ac_debug_logging_config, update_config, write_agent_local_config};
22
use crate::common::on_drop::CleanUp;
33
use crate::common::test::retry_panic;
44
use crate::common::{Args, RecipeData};
5+
use crate::linux::scenarios::INFRA_AGENT_VERSION;
56
use crate::{
6-
common::{config, nrql},
7+
common::nrql,
78
linux::{
89
self,
910
install::{install_agent_control_from_recipe, tear_down_test},
@@ -28,37 +29,62 @@ pub fn test_installation_with_infra_agent(args: Args) {
2829
chrono::Local::now().format("%Y-%m-%d_%H-%M-%S")
2930
);
3031

32+
let infra_agent_id: &str = "nr-infra";
33+
3134
info!("Setup Agent Control config");
32-
let debug_log_config = config::ac_debug_logging_config(linux::DEFAULT_LOG_PATH);
33-
let config = format!(
34-
r#"
35+
let debug_log_config = ac_debug_logging_config(linux::DEFAULT_LOG_PATH);
36+
update_config(
37+
linux::DEFAULT_AC_CONFIG_PATH,
38+
format!(
39+
r#"
3540
host_id: {test_id}
3641
agents:
3742
nr-infra:
3843
agent_type: "newrelic/com.newrelic.infrastructure:0.1.0"
3944
{debug_log_config}
4045
"#
46+
),
4147
);
42-
config::update_config(linux::DEFAULT_AC_CONFIG_PATH, config);
4348

4449
write_agent_local_config(
45-
&linux::local_config_path("nr-infra"),
46-
String::from(
50+
&linux::local_config_path(infra_agent_id),
51+
format!(
4752
r#"
4853
config_agent:
49-
status_server_enabled: true
50-
status_server_port: 18003
51-
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
52-
"#,
54+
license_key: '{{{{NEW_RELIC_LICENSE_KEY}}}}'
55+
log:
56+
level: debug
57+
config_logging:
58+
logging.yml:
59+
logs:
60+
- name: syslog
61+
file: /var/log/syslog
62+
attributes:
63+
host.id: {test_id}
64+
version: {}
65+
"#,
66+
INFRA_AGENT_VERSION
5367
),
5468
);
5569

5670
linux::service::restart_service(linux::SERVICE_NAME);
5771

5872
let nrql_query = format!(r#"SELECT * FROM SystemSample WHERE `host.id` = '{test_id}' LIMIT 1"#);
59-
info!(nrql = nrql_query, "Checking results of NRQL");
73+
info!(
74+
nrql = nrql_query,
75+
"Checking results of NRQL to check SystemSample"
76+
);
6077
let retries = 60;
6178
retry_panic(retries, Duration::from_secs(10), "nrql assertion", || {
6279
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
6380
});
81+
82+
let nrql_query = format!(r#"SELECT * FROM Log WHERE `host.id` = '{test_id}' LIMIT 1"#);
83+
info!(nrql = nrql_query, "Checking results of NRQL to check logs");
84+
let retries = 30;
85+
retry_panic(retries, Duration::from_secs(10), "nrql assertion", || {
86+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
87+
});
88+
89+
info!("Test completed successfully");
6490
}

0 commit comments

Comments
 (0)