Skip to content

Commit 229d382

Browse files
committed
feat: linux nr_infra package download on agent_type
1 parent e2c8fc9 commit 229d382

File tree

3 files changed

+95
-5
lines changed

3 files changed

+95
-5
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
@@ -85,6 +85,27 @@ variables:
8585
type: number
8686
required: false
8787
default: 18003
88+
oci:
89+
registry:
90+
description: "Package registry url"
91+
type: string
92+
required: false
93+
default: docker.io
94+
variants:
95+
ac_config_field: "oci_registry_urls"
96+
values: [ "docker.io" ]
97+
repository:
98+
description: "Package repository name"
99+
type: string
100+
required: false
101+
default: newrelic/infrastructure-agent-artifacts
102+
variants:
103+
ac_config_field: "oci_repository_urls"
104+
values: [ "newrelic/infrastructure-agent-artifacts" ]
105+
version:
106+
description: "Agent version"
107+
type: string
108+
required: true
88109
k8s:
89110
# HelmChart based sub agents should always have `chart_values`.
90111
chart_values:
@@ -197,6 +218,7 @@ deployment:
197218
NRIA_AGENT_DIR: "${nr-sub:filesystem_agent_dir}\\newrelic-infra"
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
@@ -4,3 +4,6 @@ pub mod migration;
44
pub mod nrdot_agent;
55
pub mod proxy;
66
pub mod remote_config;
7+
8+
// TODO we should get the version dynamically from the recipe itself
9+
const INFRA_AGENT_VERSION: &str = "1.72.1";

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

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
use crate::common::config::{ac_debug_logging_config, update_config, write_agent_local_config};
12
use crate::common::on_drop::CleanUp;
23
use crate::common::test::retry_panic;
34
use crate::common::{Args, RecipeData};
5+
use crate::linux::scenarios::INFRA_AGENT_VERSION;
46
use crate::{
5-
common::{config, nrql},
7+
common::nrql,
68
linux::{
79
self,
810
install::{install_agent_control_from_recipe, tear_down_test},
@@ -28,15 +30,59 @@ pub fn test_installation_with_infra_agent(args: Args) {
2830
);
2931

3032
info!("Setup Agent Control config");
31-
config::update_config_for_debug_logging(linux::DEFAULT_CONFIG_PATH, linux::DEFAULT_LOG_PATH);
32-
config::update_config_for_host_id(linux::DEFAULT_CONFIG_PATH, &test_id);
33+
let debug_log_config = ac_debug_logging_config(linux::DEFAULT_LOG_PATH);
34+
update_config(
35+
linux::DEFAULT_CONFIG_PATH,
36+
format!(
37+
r#"
38+
host_id: {test_id}
39+
agents:
40+
nr-infra:
41+
agent_type: newrelic/com.newrelic.infrastructure:0.1.0
42+
{debug_log_config}
43+
"#
44+
),
45+
);
46+
47+
write_agent_local_config(
48+
linux::DEFAULT_NR_INFRA_PATH,
49+
format!(
50+
r#"
51+
config_agent:
52+
license_key: '{{{{NEW_RELIC_LICENSE_KEY}}}}'
53+
log:
54+
level: debug
55+
config_logging:
56+
logging.yml:
57+
logs:
58+
- name: syslog
59+
file: /var/log/syslog
60+
attributes:
61+
host.id: {test_id}
62+
version: {}
63+
"#,
64+
INFRA_AGENT_VERSION
65+
),
66+
);
3367

3468
linux::service::restart_service(linux::SERVICE_NAME);
3569

3670
let nrql_query = format!(r#"SELECT * FROM SystemSample WHERE `host.id` = '{test_id}' LIMIT 1"#);
37-
info!(nrql = nrql_query, "Checking results of NRQL");
71+
info!(
72+
nrql = nrql_query,
73+
"Checking results of NRQL to check SystemSample"
74+
);
3875
let retries = 60;
3976
retry_panic(retries, Duration::from_secs(10), "nrql assertion", || {
4077
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
4178
});
79+
80+
let nrql_query = format!(r#"SELECT * FROM Log WHERE `host.id` = '{test_id}' LIMIT 1"#);
81+
info!(nrql = nrql_query, "Checking results of NRQL to check logs");
82+
let retries = 30;
83+
retry_panic(retries, Duration::from_secs(10), "nrql assertion", || {
84+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
85+
});
86+
87+
info!("Test completed successfully");
4288
}

0 commit comments

Comments
 (0)