Skip to content

Commit a79ea05

Browse files
feat(filesystem): renamed auto-generated folder
1 parent cec40ef commit a79ea05

File tree

14 files changed

+79
-71
lines changed

14 files changed

+79
-71
lines changed

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ nfpms: # deb and rpm are only built for linux targets
159159
type: dir
160160
file_info:
161161
mode: 0700
162-
- dst: /var/lib/newrelic-agent-control/auto-generated
162+
- dst: /var/lib/newrelic-agent-control/filesystem
163163
type: dir
164164
file_info:
165165
mode: 0700

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ deployment:
183183
- id: newrelic-infra
184184
path: ${nr-sub:packages.infra-agent.dir}\newrelic-infra.exe
185185
args: >-
186-
--config=${nr-sub:autogenerated_agent_dir}\config\newrelic-infra.yaml
186+
--config=${nr-sub:filesystem_agent_dir}\config\newrelic-infra.yaml
187187
env:
188188
NRIA_CUSTOM_PLUGIN_INSTALLATION_DIR: "${nr-sub:packages.infra-agent.dir}\\integrations"
189189
NRIA_SAFE_BIN_DIR: "${nr-sub:packages.infra-agent.dir}\\integrations"
190-
NRIA_PLUGIN_DIR: "${nr-sub:autogenerated_agent_dir}\\integrations.d"
191-
NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:autogenerated_agent_dir}\\logging.d"
190+
NRIA_PLUGIN_DIR: "${nr-sub:filesystem_agent_dir}\\integrations.d"
191+
NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:filesystem_agent_dir}\\logging.d"
192192
NRIA_STATUS_SERVER_ENABLED: true
193193
NRIA_STATUS_SERVER_PORT: "${nr-var:health_port}"
194194
NR_HOST_ID: "${nr-ac:host_id}"
@@ -219,10 +219,10 @@ deployment:
219219
- id: newrelic-infra
220220
path: /usr/bin/newrelic-infra
221221
args: >-
222-
--config=${nr-sub:autogenerated_agent_dir}/config/newrelic-infra.yaml
222+
--config=${nr-sub:filesystem_agent_dir}/config/newrelic-infra.yaml
223223
env:
224-
NRIA_PLUGIN_DIR: "${nr-sub:autogenerated_agent_dir}/integrations.d"
225-
NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:autogenerated_agent_dir}/logging.d"
224+
NRIA_PLUGIN_DIR: "${nr-sub:filesystem_agent_dir}/integrations.d"
225+
NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:filesystem_agent_dir}/logging.d"
226226
NRIA_STATUS_SERVER_ENABLED: true
227227
NRIA_STATUS_SERVER_PORT: "${nr-var:health_port}"
228228
NR_HOST_ID: "${nr-ac:host_id}"

agent-control/agent-type-registry/newrelic/com.newrelic.opentelemetry.collector-0.1.0.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variables:
77
description: "Newrelic otel collector configuration"
88
type: yaml
99
required: false
10-
default: {}
10+
default: { }
1111
backoff_delay:
1212
description: "seconds until next retry if agent fails to start"
1313
type: string
@@ -33,12 +33,12 @@ variables:
3333
description: "Newrelic otel collector chart values"
3434
type: yaml
3535
required: false
36-
default: {}
36+
default: { }
3737
global:
3838
description: "Global values for the chart"
3939
type: yaml
4040
required: false
41-
default: {}
41+
default: { }
4242
chart_version:
4343
description: "Newrelic otel collector chart version"
4444
type: string
@@ -56,7 +56,7 @@ variables:
5656
default: "https://helm-charts.newrelic.com"
5757
variants:
5858
ac_config_field: "chart_repository_urls"
59-
values: ["https://helm-charts.newrelic.com"]
59+
values: [ "https://helm-charts.newrelic.com" ]
6060
secret_reference:
6161
description: "HelmRepository secret reference (secretRef)"
6262
type: yaml
@@ -89,7 +89,7 @@ deployment:
8989
id: nrdot-collector
9090
path: /usr/bin/nrdot-collector
9191
args: >-
92-
--config=${nr-sub:autogenerated_agent_dir}/otel-config/config.yaml
92+
--config=${nr-sub:filesystem_agent_dir}/otel-config/config.yaml
9393
env:
9494
# sets the otel-collector "env" source resource detector
9595
OTEL_RESOURCE_ATTRIBUTES: "host.id=${nr-ac:host_id}"

agent-control/agent-type-registry/newrelic/io.opentelemetry.collector-0.1.0.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variables:
1010
description: "Newrelic otel collector configuration"
1111
type: yaml
1212
required: false
13-
default: {}
13+
default: { }
1414
backoff_delay:
1515
description: "seconds until next retry if agent fails to start"
1616
type: string
@@ -36,12 +36,12 @@ variables:
3636
description: "Newrelic otel collector chart values"
3737
type: yaml
3838
required: false
39-
default: {}
39+
default: { }
4040
global:
4141
description: "Global values for the chart"
4242
type: yaml
4343
required: false
44-
default: {}
44+
default: { }
4545
chart_version:
4646
description: "Newrelic otel collector chart version"
4747
type: string
@@ -59,7 +59,7 @@ variables:
5959
default: "https://helm-charts.newrelic.com"
6060
variants:
6161
ac_config_field: "chart_repository_urls"
62-
values: ["https://helm-charts.newrelic.com"]
62+
values: [ "https://helm-charts.newrelic.com" ]
6363
secret_reference:
6464
description: "HelmRepository secret reference (secretRef)"
6565
type: yaml
@@ -92,7 +92,7 @@ deployment:
9292
id: nrdot-collector
9393
path: /usr/bin/nrdot-collector
9494
args: >-
95-
--config=${nr-sub:autogenerated_agent_dir}/otel-config/config.yaml
95+
--config=${nr-sub:filesystem_agent_dir}/otel-config/config.yaml
9696
env:
9797
# sets the otel-collector "env" source resource detector
9898
OTEL_RESOURCE_ATTRIBUTES: "host.id=${nr-ac:host_id}"

agent-control/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ fn generate_agent_type_registry() {
4040

4141
let out_dir = env::var_os("OUT_DIR").expect("Could not load the target registry file path");
4242
let dest_path = Path::new(&out_dir).join(GENERATED_REGISTRY_FILE);
43-
fs::write(dest_path, contents).expect("Could not write the auto-generated registry file");
43+
fs::write(dest_path, contents).expect("Could not write the filesystem registry file");
4444
}

agent-control/src/agent_control/defaults.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub const STORE_KEY_OPAMP_DATA_CONFIG: &StoreKey = "remote_config";
8181
pub const STORE_KEY_INSTANCE_ID: &StoreKey = "instance_id";
8282
pub const DYNAMIC_AGENT_TYPE_DIR: &str = "dynamic-agent-types";
8383
pub const INSTANCE_ID_FILENAME: &str = "instance_id.yaml";
84-
pub const GENERATED_FOLDER_NAME: &str = "auto-generated";
84+
pub const AGENT_FILESYSTEM_FOLDER_NAME: &str = "filesystem";
8585
pub const PACKAGES_FOLDER_NAME: &str = "packages";
8686
pub const AGENT_CONTROL_LOG_FILENAME: &str = "newrelic-agent-control.log";
8787
pub const STDOUT_LOG_PREFIX: &str = "stdout.log";

agent-control/src/agent_type/agent_attributes.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::variable::{Variable, namespace::Namespace};
22
use crate::agent_control::agent_id::AgentID;
3-
use crate::agent_control::defaults::GENERATED_FOLDER_NAME;
3+
use crate::agent_control::defaults::AGENT_FILESYSTEM_FOLDER_NAME;
44
use std::{collections::HashMap, path::PathBuf};
55
use thiserror::Error;
66
use tracing::debug;
@@ -10,7 +10,7 @@ use tracing::debug;
1010
pub struct AgentAttributes {
1111
/// sub-agent Agent ID
1212
agent_id: String,
13-
auto_generated_dir: PathBuf,
13+
agent_filesystem_dir: PathBuf,
1414
remote_dir: PathBuf,
1515
}
1616

@@ -20,19 +20,21 @@ pub struct AgentAttributesCreateError(String);
2020

2121
impl AgentAttributes {
2222
pub const VARIABLE_SUB_AGENT_ID: &'static str = "agent_id";
23-
pub const VARIABLE_GENERATED_DIR: &'static str = "autogenerated_agent_dir";
23+
pub const VARIABLE_FILESYSTEM_AGENT_DIR: &'static str = "filesystem_agent_dir";
2424
pub const VARIABLE_REMOTE_DIR: &'static str = "remote_dir";
2525

2626
pub fn try_new(
2727
agent_id: AgentID,
2828
remote_dir: PathBuf,
2929
) -> Result<Self, AgentAttributesCreateError> {
3030
if let AgentID::SubAgent(agent_id) = agent_id {
31-
let auto_generated_dir = remote_dir.join(GENERATED_FOLDER_NAME).join(&agent_id);
32-
debug!(id = %agent_id, "auto-generated directory path set to {}", auto_generated_dir.display());
31+
let agent_filesystem_dir = remote_dir
32+
.join(AGENT_FILESYSTEM_FOLDER_NAME)
33+
.join(&agent_id);
34+
debug!(id = %agent_id, "filesystem directory path set to {}", agent_filesystem_dir.display());
3335
Ok(Self {
3436
agent_id: agent_id.to_string(),
35-
auto_generated_dir,
37+
agent_filesystem_dir,
3638
remote_dir,
3739
})
3840
} else {
@@ -48,8 +50,8 @@ impl AgentAttributes {
4850
Variable::new_final_string_variable(&self.agent_id),
4951
),
5052
(
51-
Namespace::SubAgent.namespaced_name(Self::VARIABLE_GENERATED_DIR),
52-
Variable::new_final_string_variable(self.auto_generated_dir.to_string_lossy()),
53+
Namespace::SubAgent.namespaced_name(Self::VARIABLE_FILESYSTEM_AGENT_DIR),
54+
Variable::new_final_string_variable(self.agent_filesystem_dir.to_string_lossy()),
5355
),
5456
(
5557
Namespace::SubAgent.namespaced_name(Self::VARIABLE_REMOTE_DIR),

agent-control/src/agent_type/definition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pub fn include_packages_variables(
170170
mut variables: Variables,
171171
packages: &RenderedPackages,
172172
) -> Result<Variables, AgentTypeError> {
173-
// Return early if no packages to avoid retrieving the auto-generated dir unnecessarily
173+
// Return early if no packages to avoid retrieving the filesystem dir unnecessarily
174174
if packages.is_empty() {
175175
return Ok(variables);
176176
}

agent-control/src/agent_type/runtime_config/on_host.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ packages:
201201
// Base variables must include autogenerated dir
202202
let mut vars: Variables = Variables::new();
203203
vars.insert(
204-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR),
205-
Variable::new_final_string_variable("/autogenerated"),
204+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
205+
Variable::new_final_string_variable("/filesystem"),
206206
);
207207
vars.insert(
208208
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_REMOTE_DIR),
@@ -239,8 +239,8 @@ executables:
239239

240240
let mut vars: Variables = Variables::new();
241241
vars.insert(
242-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR),
243-
Variable::new_final_string_variable("/tmp/auto/generated"),
242+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
243+
Variable::new_final_string_variable("/tmp/auto/filesystem"),
244244
);
245245
let err = on_host.template_with(&vars).unwrap_err();
246246
assert!(
@@ -269,8 +269,8 @@ packages:
269269

270270
let mut vars: Variables = Variables::new();
271271
vars.insert(
272-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR),
273-
Variable::new_final_string_variable("/tmp/auto/autogenerated"),
272+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
273+
Variable::new_final_string_variable("/tmp/auto/filesystem"),
274274
);
275275
vars.insert(
276276
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_REMOTE_DIR),

agent-control/src/agent_type/runtime_config/on_host/filesystem.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! This includes files and directories that should be created for the sub-agent at runtime,
44
//! based on templated content and paths. The paths are always relative to the sub-agent's
55
//! dedicated directory created by agent-control
6-
//! (usually something like `/var/lib/newrelic-agent-control/auto-generated/<SUB_AGENT_ID>`).
6+
//! (usually something like `/var/lib/newrelic-agent-control/filesystem/<SUB_AGENT_ID>`).
77
//! The files are created in a dedicated `files/` subdirectory, while directories are created in
88
//! a dedicated `directories/` subdirectory, to avoid name clashes.
99
@@ -126,8 +126,11 @@ impl Templateable for FileSystem {
126126
type Output = rendered::FileSystem;
127127

128128
fn template_with(self, variables: &Variables) -> Result<Self::Output, AgentTypeError> {
129-
if let Some(TrivialValue::String(generated_dir)) = variables
130-
.get(&Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR))
129+
if let Some(TrivialValue::String(filesystem_dir)) = variables
130+
.get(
131+
&Namespace::SubAgent
132+
.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
133+
)
131134
.and_then(Variable::get_final_value)
132135
{
133136
let filesystem = self
@@ -136,18 +139,18 @@ impl Templateable for FileSystem {
136139
.map(|(k, v)| {
137140
Ok((
138141
// The only place where we construct a `SafePath` directly, prepending the
139-
// sub-agent's auto-generated directory to the user-provided relative path.
142+
// sub-agent's filesystem directory to the user-provided relative path.
140143
// FIXME: when we fix the templating and make the agent type definitions
141144
// type-safe, we will make sure to always build correct "final paths" here.
142-
SafePath(PathBuf::from(generated_dir.clone()).join(k)),
145+
SafePath(PathBuf::from(filesystem_dir.clone()).join(k)),
143146
v.template_with(variables)?,
144147
))
145148
})
146149
.collect::<Result<HashMap<_, _>, AgentTypeError>>()?;
147150
Ok(rendered::FileSystem(filesystem))
148151
} else {
149152
Err(AgentTypeError::MissingValue(
150-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR),
153+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
151154
))
152155
}
153156
}
@@ -304,7 +307,7 @@ mod tests {
304307
#[test]
305308
fn valid_filepath_rendering() {
306309
let variables = Variables::from_iter(vec![(
307-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR),
310+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
308311
Variable::new_final_string_variable("/base/dir"),
309312
)]);
310313

@@ -334,7 +337,7 @@ mod tests {
334337

335338
#[test]
336339
fn invalid_filepath_rendering_nonexisting_subagent_basepath() {
337-
// If the sub-agent variable (nr-sub) containing the agent's auto-generated dir is missing,
340+
// If the sub-agent variable (nr-sub) containing the agent's filesystem dir is missing,
338341
// templating must fail.
339342
let variables = Variables::default();
340343

@@ -354,7 +357,7 @@ mod tests {
354357
rendered_err.to_string(),
355358
format!(
356359
"missing value for key: {}",
357-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR)
360+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR)
358361
)
359362
);
360363
}
@@ -436,7 +439,7 @@ mod tests {
436439
let parsed = parsed.unwrap();
437440
let variables = Variables::from_iter(vec![
438441
(
439-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR),
442+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
440443
Variable::new_final_string_variable("/test/base/dir"),
441444
),
442445
(
@@ -480,7 +483,7 @@ mod tests {
480483
let parsed = parsed.unwrap();
481484
let variables = Variables::from_iter(vec![
482485
(
483-
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_GENERATED_DIR),
486+
Namespace::SubAgent.namespaced_name(AgentAttributes::VARIABLE_FILESYSTEM_AGENT_DIR),
484487
Variable::new_final_string_variable("/test/base/dir"),
485488
),
486489
(

0 commit comments

Comments
 (0)