Skip to content

Commit c1e5c88

Browse files
authored
feat: directory support, map[string]yaml var type, migration (#1685)
* feat: add map[string]yaml var type * feat: extend filesystem (#1699) * fix: use `relative_path` for file entry info * docs: type * feat: extend filesystem to fully support directories * feat: a specific dir for each filesystem entity (files, dirs) * test: templating * test: move test-only impls to test module * test: templating * test: proper yaml rendering * docs: detail how this module works * feat: SafePath -> PathBuf * feat(rendering): generate writable file list * feat: rendering filesystem entry list * style: rename path field * test: rendering expected file entries * test(integration): fix filesystem ops * style: trace level logs to paths written * refactor: migrate host agent types to filesystem * style: use capital letters * docs: clarify * chore: remove unused From impl * chore: remove leftover * feat: merge files and directories * refactor: make writes more safe by hiding rendering function The function `FileSystem::rendered` was public before, which could cause access to the internal `HashMap<PathBuf, String>`. If bound as mutable, it could be modified to write to unintended locations. Now the creation of `RenderedFileSystemEntries` is safer and doesn't provide visibility to the paths, only to write. * test: fix rendered paths comparison * fix: correctly handle yaml templating
1 parent 37f2f75 commit c1e5c88

File tree

12 files changed

+664
-202
lines changed

12 files changed

+664
-202
lines changed

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,19 @@ variables:
55
on_host:
66
config_agent:
77
description: "Newrelic infra configuration"
8-
type: file
8+
type: yaml
99
required: false
1010
default: ""
11-
file_path: "newrelic-infra.yml"
1211
config_integrations:
1312
description: "map of YAML configs for the OHIs"
14-
type: map[string]file
13+
type: map[string]yaml
1514
required: false
16-
default: { }
17-
file_path: "integrations.d"
15+
default: {}
1816
config_logging:
1917
description: "map of YAML config for logging"
20-
type: map[string]file
18+
type: map[string]yaml
2119
required: false
22-
default: { }
23-
file_path: "logging.d"
20+
default: {}
2421
backoff_delay:
2522
description: "seconds until next retry if agent fails to start"
2623
type: string
@@ -48,28 +45,28 @@ variables:
4845
description: "newrelic-infrastructure chart values"
4946
type: yaml
5047
required: false
51-
default: { }
48+
default: {}
5249
nri-metadata-injection:
5350
description: "nri-metadata-injection chart values"
5451
type: yaml
5552
required: false
56-
default: { }
53+
default: {}
5754
kube-state-metrics:
5855
description: "kube-state-metrics chart values"
5956
type: yaml
6057
required: false
61-
default: { }
58+
default: {}
6259
nri-kube-events:
6360
description: "nri-kube-events chart values"
6461
type: yaml
6562
required: false
66-
default: { }
63+
default: {}
6764
# Global values must have their own key, even if there is only one sub-chart.
6865
global:
6966
description: "Global chart values"
7067
type: yaml
7168
required: false
72-
default: { }
69+
default: {}
7370
# HelmChart based sub agents should always have `chart_version`.
7471
chart_version:
7572
description: "nri-bundle chart version"
@@ -101,7 +98,7 @@ variables:
10198
type: yaml
10299
required: false
103100
default: null
104-
101+
105102
deployment:
106103
on_host:
107104
enable_file_logging: ${nr-var:enable_file_logging}
@@ -116,14 +113,20 @@ deployment:
116113
path: /usr/bin/newrelic-infra
117114
args: --version
118115
regex: \d+\.\d+\.\d+
116+
filesystem:
117+
config:
118+
newrelic-infra.yaml: |
119+
${nr-var:config_agent}
120+
integrations.d: ${nr-var:config_integrations}
121+
logging.d: ${nr-var:config_logging}
119122
executables:
120123
- id: newrelic-infra
121124
path: /usr/bin/newrelic-infra
122125
args: >-
123-
--config=${nr-var:config_agent}
126+
--config=${nr-sub:autogenerated_agent_dir}/config/newrelic-infra.yaml
124127
env:
125-
NRIA_PLUGIN_DIR: "${nr-var:config_integrations}"
126-
NRIA_LOGGING_CONFIGS_DIR: "${nr-var:config_logging}"
128+
NRIA_PLUGIN_DIR: "${nr-sub:autogenerated_agent_dir}/integrations.d"
129+
NRIA_LOGGING_CONFIGS_DIR: "${nr-sub:autogenerated_agent_dir}/logging.d"
127130
NRIA_STATUS_SERVER_ENABLED: true
128131
NRIA_STATUS_SERVER_PORT: "${nr-var:health_port}"
129132
NR_HOST_ID: "${nr-ac:host_id}"
@@ -216,7 +219,7 @@ deployment:
216219
newrelic-prometheus-agent:
217220
enabled: false
218221
newrelic-k8s-metrics-adapter:
219-
enabled: false
222+
enabled: false
220223
# Flux [HelmRelease](https://fluxcd.io/flux/components/helmreleases/) that installs the nri-bundle chart.
221224
release:
222225
apiVersion: helm.toolkit.fluxcd.io/v2
@@ -240,7 +243,7 @@ deployment:
240243
chart: ${nr-var:chart_name}
241244
# This is where the chart version to be installed is defined. Whenever AC updates this Flux triggers a reconciliation.
242245
version: ${nr-var:chart_version}
243-
# This value gets rendered even if not specified so, even 'ChartVersion' is the default, it is required to specify
246+
# This value gets rendered even if not specified so, even 'ChartVersion' is the default, it is required to specify
244247
# it to avoid the drift detection on AC supervisor, and trigger re-apply on each interval.
245248
reconcileStrategy: ChartVersion
246249
sourceRef:

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ variables:
55
on_host:
66
config:
77
description: "Newrelic otel collector configuration"
8-
type: file
8+
type: yaml
99
required: false
10-
default: ""
11-
file_path: "config.yaml"
10+
default: {}
1211
backoff_delay:
1312
description: "seconds until next retry if agent fails to start"
1413
type: string
@@ -34,12 +33,12 @@ variables:
3433
description: "Newrelic otel collector chart values"
3534
type: yaml
3635
required: false
37-
default: { }
36+
default: {}
3837
global:
3938
description: "Global values for the chart"
4039
type: yaml
4140
required: false
42-
default: { }
41+
default: {}
4342
chart_version:
4443
description: "Newrelic otel collector chart version"
4544
type: string
@@ -81,12 +80,16 @@ deployment:
8180
path: /usr/bin/nrdot-collector-host
8281
args: -v
8382
regex: \d+\.\d+\.\d+
83+
filesystem:
84+
otel-config:
85+
config.yaml: |
86+
${nr-var:config}
8487
executables:
8588
- # Important to note the binary name is nrdot-collector-host matching the new nrdot binary
8689
id: nrdot-collector-host
8790
path: /usr/bin/nrdot-collector-host
8891
args: >-
89-
--config=${nr-var:config}
92+
--config=${nr-sub:autogenerated_agent_dir}/otel-config/config.yaml
9093
--feature-gates=-pkg.translator.prometheus.NormalizeName
9194
env:
9295
# sets the otel-collector "env" source resource detector

0 commit comments

Comments
 (0)