Skip to content

Commit 8986135

Browse files
authored
fix: infra config value quoting (#1746)
* fix: remote config * fix: interpolate back some of the values * deleteme: print rendered remote config * deleteme: print incoming remote config
1 parent 8f0f7a1 commit 8986135

File tree

5 files changed

+58
-33
lines changed

5 files changed

+58
-33
lines changed

agent-control/src/opamp/remote_config/validators/regexes.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,19 @@ pub(super) mod tests {
156156
fn test_validate() {
157157
let content = r#"
158158
health_port: 18003
159-
config_agent: |+
159+
config_agent:
160160
staging: true
161161
enable_process_metrics: true
162162
status_server_enabled: true
163163
status_server_port: 18003
164164
log:
165165
level: info
166-
license_key: {{NEW_RELIC_LICENSE_KEY}}
166+
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
167167
custom_attributes:
168168
nr_deployed_by: newrelic-cli
169169
170170
config_integrations:
171-
docker-config.yml: |
171+
docker-config.yml:
172172
integrations:
173173
- name: nri-docker
174174
when:
@@ -214,7 +214,7 @@ pub(super) mod tests {
214214
}
215215

216216
pub static VALID_ONHOST_NRDOT_CONFIG: &str = r#"
217-
config: |
217+
config:
218218
219219
extensions:
220220
health_check:
@@ -380,7 +380,7 @@ config: |
380380
attributes:
381381
- key: host.display_name
382382
action: upsert
383-
value: {{ display_name }}
383+
value: '{{ display_name }}'
384384
385385
resourcedetection:
386386
detectors: ["env", "system"]
@@ -403,7 +403,7 @@ config: |
403403
otlp:
404404
endpoint: staging-otlp.nr-data.net:4317
405405
headers:
406-
api-key: {{ nr_license_key_canaries }}
406+
api-key: '{{ nr_license_key_canaries }}'
407407
408408
service:
409409
"#;
@@ -518,8 +518,8 @@ config: |
518518
################################################
519519
520520
# Configuration for the Infrastructure Agent
521-
config_agent: |
522-
license_key: {{ NEW_RELIC_LICENSE_KEY }}
521+
config_agent:
522+
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
523523
staging: true
524524
display_name: host-display-name
525525
enable_process_metrics: true
@@ -529,7 +529,7 @@ config_agent: |
529529
530530
# Configuration for New Relic Integrations
531531
config_integrations:
532-
flex.yml: |
532+
flex.yml:
533533
integrations:
534534
- name: nri-flex
535535
offset: 10s
@@ -564,8 +564,8 @@ config_integrations:
564564
################################################
565565
566566
# Configuration for the Infrastructure Agent
567-
config_agent: |
568-
license_key: {{ NEW_RELIC_LICENSE_KEY }}
567+
config_agent:
568+
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
569569
staging: true
570570
display_name: host-display-name
571571
enable_process_metrics: true
@@ -605,8 +605,8 @@ config_integrations:
605605
################################################
606606
607607
# Configuration for the Infrastructure Agent
608-
config_agent: |
609-
license_key: {{ NEW_RELIC_LICENSE_KEY }}
608+
config_agent:
609+
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
610610
staging: true
611611
display_name: host-display-name
612612
enable_process_metrics: true
@@ -616,14 +616,14 @@ config_agent: |
616616
617617
# Configuration for New Relic Integrations
618618
config_integrations:
619-
mysql.yml: |
619+
mysql.yml:
620620
integrations:
621621
- name: nri-mysql
622622
offset: 10s
623623
config:
624624
name: RandomNumbers
625625
exec: an extra command
626-
mysql.yml: |
626+
mysql.yml:
627627
integrations:
628628
- name: nri-mysql
629629
env:
@@ -646,8 +646,8 @@ config_integrations:
646646
################################################
647647
648648
# Configuration for the Infrastructure Agent
649-
config_agent: |
650-
license_key: {{ NEW_RELIC_LICENSE_KEY }}
649+
config_agent:
650+
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
651651
staging: true
652652
display_name: host-display-name
653653
enable_process_metrics: true
@@ -657,7 +657,7 @@ config_agent: |
657657
658658
# Configuration for New Relic Integrations
659659
config_integrations:
660-
apache.yml: |
660+
apache.yml:
661661
- name: nri-apache
662662
env:
663663
INVENTORY: "true"
@@ -679,8 +679,8 @@ config_integrations:
679679
################################################
680680
681681
# Configuration for the Infrastructure Agent
682-
config_agent: |
683-
license_key: {{ NEW_RELIC_LICENSE_KEY }}
682+
config_agent:
683+
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
684684
staging: true
685685
display_name: host-display-name
686686
enable_process_metrics: true
@@ -690,7 +690,7 @@ config_agent: |
690690
691691
# Configuration for New Relic Integrations
692692
config_integrations:
693-
apache.yml: |
693+
apache.yml:
694694
- name: nri-apache
695695
env:
696696
INVENTORY: "true"

test/onhost-canaries/ansible/install_ac_with_basic_config.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@
7272
copy:
7373
dest: /etc/newrelic-agent-control/fleet/agents.d/infra/values/values.yaml
7474
content: |
75-
config_agent: |+
76-
staging: {{ infra_staging }}
75+
{% raw %}
76+
config_agent:
77+
staging: {% endraw -%} {{ infra_staging }} {%- raw %}
7778
enable_process_metrics: true
7879
status_server_enabled: true
7980
status_server_port: 18003
80-
license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}}
81+
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
82+
{% endraw %}
8183
8284
- name: Add license to service
8385
shell: echo 'NEW_RELIC_LICENSE_KEY="{{ nr_license_key }}"' >> {{ agent_control_service_conf }}

test/onhost-e2e/ansible/ebpf_agent.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@
9595
copy:
9696
dest: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml
9797
content: |
98-
config_agent: |+
98+
{% raw %}
99+
config_agent:
99100
status_server_enabled: true
100101
status_server_port: 18003
101-
license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}}
102+
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
103+
{% endraw %}
102104
103105
- name: Restart Agent Control
104106
include_role:

test/onhost-e2e/ansible/migration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
status_server_enabled: true
3838
status_server_port: 18003
3939
license_key: {{ nr_license_key }}
40-
40+
4141
- name: Install docker
4242
include_role:
4343
name: caos.ansible_roles.docker_install
@@ -67,7 +67,7 @@
6767
labels:
6868
test_id: {{ test_id }}
6969
test_installed_agent: infra_agent
70-
70+
7171
- name: Restart Infra Agent
7272
include_role:
7373
name: caos.ansible_roles.service_status

test/onhost-e2e/ansible/remote_config.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
---
22
# This test expects to have a created Fleet with an Active deployment containing an infra-agent
33
# remote configuration containing:
4-
# config_agent: |+
4+
# ```yaml
5+
# config_agent:
56
# status_server_enabled: true
67
# status_server_port: 18003
7-
# license_key: {{NEW_RELIC_LICENSE_KEY}}
8+
# license_key: '{{NEW_RELIC_LICENSE_KEY}}'
89
# custom_attributes:
910
# config_origin: remote
10-
# test_id: {{TEST_ID}}
11+
# test_id: '{{TEST_ID}}'
12+
# ```
13+
# Remember to pass `{% raw %}` and `{% endraw %}` to escape the quoting and braces.
1114
# This would make that the infra agent reported metrics contain a `config_origin: remote` attribute.
1215

1316
- name: Install AC and assert a remote config is applied.
@@ -96,13 +99,15 @@
9699
copy:
97100
dest: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml
98101
content: |
102+
{% raw %}
99103
config_agent:
100104
status_server_enabled: true
101105
status_server_port: 18003
102-
license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}}
106+
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
103107
custom_attributes:
104108
config_origin: local
105-
test_id: {{'{{'}}TEST_ID{{'}}'}}
109+
test_id: '{{TEST_ID}}'
110+
{% endraw %}
106111
107112
- name: Restart Agent Control
108113
include_role:
@@ -152,5 +157,21 @@
152157
debug:
153158
var: ac_logs.stdout_lines
154159

160+
- name: Inspect the remote values
161+
shell: cat /var/lib/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml
162+
register: remote_values
163+
164+
- name: Debug remote values
165+
debug:
166+
var: remote_values.stdout_lines
167+
168+
- name: Inspect the rendered config file from remote
169+
shell: cat /var/lib/newrelic-agent-control/auto-generated/nr-infra/config/newrelic-infra.yaml
170+
register: rendered_config
171+
172+
- name: Debug rendered config
173+
debug:
174+
var: rendered_config.stdout_lines
175+
155176
- name: Cleanup
156177
include_tasks: ./tasks/clean_all.yaml

0 commit comments

Comments
 (0)