Skip to content

Commit 80f4e0e

Browse files
fix: Super agent recipe final step check status endpoint and rename to Agent Control (#1102)
* Super agent recipe final step check status endpoint * Rename Super Agent to Agent Control on all displays * Refine the name for the Agent Control display * Fix super-agent tests to look for new validated output * Remove unsupported OS from the super-agent tests
1 parent dd4076f commit 80f4e0e

31 files changed

+223
-373
lines changed

recipes/newrelic/infrastructure/super-agent/debian.yml

Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# https://github.com/newrelic/open-install-library/blob/main/docs/recipe-spec/recipe-spec.md#schema-definition
33

44
name: super-agent
5-
displayName: New Relic Super Agent
6-
description: New Relic install recipe for the Super Agent
5+
displayName: Agent Control
6+
description: New Relic install recipe for Agent Control
77
repository: https://github.com/newrelic/newrelic-super-agent
88

99
installTargets:
@@ -92,7 +92,7 @@ install:
9292
- task: update_otel_end_point
9393
- task: migrate_newrelic_infra_config
9494
- task: restart_super_agent
95-
- task: assert_super_agent_started
95+
- task: assert_super_agent_status_ok
9696
- task: signal_recipe_applied
9797
- task: post_install
9898

@@ -175,18 +175,18 @@ install:
175175
if [ -n "{{.DEBIAN_CODENAME}}" ]; then
176176
IS_AGENT_AVAILABLE=$(curl -Is {{.NEW_RELIC_DOWNLOAD_URL}}preview/linux/apt/dists/{{.DEBIAN_CODENAME}}/InRelease | grep " 2[0-9][0-9] " | wc -l)
177177
if [ $IS_AGENT_AVAILABLE -eq 0 ] ; then
178-
echo "there is no newrelic super agent available for the distribution with codename '{{.DEBIAN_CODENAME}}'." >&2
178+
echo "there is no New Relic Agent Control available for the distribution with codename '{{.DEBIAN_CODENAME}}'." >&2
179179
exit 131
180180
fi
181181
else
182182
if [ -n "{{.DEBIAN_VERSION_CODENAME}}" ]; then
183183
IS_INFRA_AVAILABLE=$(curl -Is {{.NEW_RELIC_DOWNLOAD_URL}}preview/linux/apt/dists/{{.DEBIAN_VERSION_CODENAME}}/InRelease | grep " 2[0-9][0-9] " | wc -l)
184184
if [ $IS_INFRA_AVAILABLE -eq 0 ] ; then
185-
echo "there is no newrelic super agent available for the distribution with version codename '{{.DEBIAN_VERSION_CODENAME}}'." >&2
185+
echo "there is no New Relic Agent Control available for the distribution with version codename '{{.DEBIAN_VERSION_CODENAME}}'." >&2
186186
exit 131
187187
fi
188188
else
189-
echo "there is no newrelic super agent available for the distribution, no version codename was found." >&2
189+
echo "there is no New Relic Agent Control available for the distribution, no version codename was found." >&2
190190
exit 131
191191
fi
192192
fi
@@ -198,7 +198,7 @@ install:
198198

199199
cleanup:
200200
# skipping this task if .nr-cli exists
201-
status:
201+
status:
202202
- test -f /etc/newrelic-super-agent/.nr-cli
203203
cmds:
204204
- |
@@ -207,8 +207,8 @@ install:
207207
fi
208208
209209
setup_infra_license:
210-
status:
211-
- test -f /etc/newrelic-super-agent/.nr-cli
210+
status:
211+
- test -f /etc/newrelic-super-agent/.nr-cli
212212
cmds:
213213
- |
214214
if [ "{{.NR_CLI_INFRA_AGENT}}" != "false" ] ; then
@@ -227,7 +227,7 @@ install:
227227
if [ "{{.NR_SA_MIGRATE_INFRA_CONFIG}}" == "true" ] || [ "{{.NEW_RELIC_ASSUME_YES}}" == "true" ] ; then
228228
touch /etc/newrelic-infra-do-migrate
229229
else
230-
printf "\nWould you like to migrate this newrelic-infra config to use it with the newrelic super agent? (y/N): "
230+
printf "\nWould you like to migrate this newrelic-infra config to use it with New Relic Agent Control? (y/N): "
231231
read -r MIGRATE_NEWRELIC_INFRA_CONFIG
232232
MIGRATE_NEWRELIC_INFRA_CONFIG=${MIGRATE_NEWRELIC_INFRA_CONFIG:-N}
233233
@@ -253,8 +253,8 @@ install:
253253
echo '{{.NRIA_CUSTOM_ATTRIBUTES}}' >> /etc/newrelic-infra.yml
254254
fi
255255
setup_infra_proxy:
256-
status:
257-
- test -f /etc/newrelic-super-agent/.nr-cli
256+
status:
257+
- test -f /etc/newrelic-super-agent/.nr-cli
258258
cmds:
259259
- |
260260
if [ "{{.NR_CLI_INFRA_AGENT}}" != "false" ] && [ ! -z "$HTTPS_PROXY" ]; then
@@ -368,9 +368,9 @@ install:
368368
fi
369369
silent: true
370370

371-
# If configured to do so, migrate the newrelic-infra configuration for usage with the super agent
371+
# If configured to do so, migrate the newrelic-infra configuration for usage with New Relic Agent Control
372372
migrate_newrelic_infra_config:
373-
status:
373+
status:
374374
- test -f /etc/newrelic-super-agent/.nr-cli
375375
cmds:
376376
- |
@@ -379,18 +379,18 @@ install:
379379
newrelic-config-migrate
380380
fi
381381
382-
# Add NR Ingest Key as ENV Var for the Super Agent Systemd service (used by Infra Agent and Otel)
382+
# Add NR Ingest Key as ENV Var for the super-agent Systemd service (used by Infra Agent and Otel)
383383
update_otel_license_key:
384-
status:
385-
- test -f /etc/newrelic-super-agent/.nr-cli
384+
status:
385+
- test -f /etc/newrelic-super-agent/.nr-cli
386386
cmds:
387387
- |
388388
sed -i "/^NEW_RELIC_LICENSE_KEY/d" /etc/newrelic-super-agent/newrelic-super-agent.conf
389389
echo 'NEW_RELIC_LICENSE_KEY="{{.NEW_RELIC_LICENSE_KEY}}"' >> /etc/newrelic-super-agent/newrelic-super-agent.conf
390390
391391
update_otel_mem_limit:
392-
status:
393-
- test -f /etc/newrelic-super-agent/.nr-cli
392+
status:
393+
- test -f /etc/newrelic-super-agent/.nr-cli
394394
cmds:
395395
- |
396396
if [ "{{.NR_CLI_NRDOT}}" != "false" ]; then
@@ -399,8 +399,8 @@ install:
399399
400400
# Add OTLP Endpoint as ENV Var for the Super Agent Systemd service
401401
update_otel_end_point:
402-
status:
403-
- test -f /etc/newrelic-super-agent/.nr-cli
402+
status:
403+
- test -f /etc/newrelic-super-agent/.nr-cli
404404
cmds:
405405
- |
406406
if [ "{{.NR_CLI_NRDOT}}" != "false" ]; then
@@ -414,8 +414,8 @@ install:
414414
fi
415415
416416
config_supervisors:
417-
status:
418-
- test -f /etc/newrelic-super-agent/.nr-cli
417+
status:
418+
- test -f /etc/newrelic-super-agent/.nr-cli
419419
cmds:
420420
- |
421421
if [ "{{.NR_CLI_INFRA_AGENT}}" = "false" ] && [ "{{.NR_CLI_NRDOT}}" = "false" ]; then
@@ -441,8 +441,8 @@ install:
441441
fi
442442
443443
config_fleet_id:
444-
status:
445-
- test -f /etc/newrelic-super-agent/.nr-cli
444+
status:
445+
- test -f /etc/newrelic-super-agent/.nr-cli
446446
cmds:
447447
- |
448448
if [ ! -z "{{.NR_CLI_FLEET_ID}}" ] ; then
@@ -451,8 +451,8 @@ install:
451451
fi
452452
453453
config_opamp:
454-
status:
455-
- test -f /etc/newrelic-super-agent/.nr-cli
454+
status:
455+
- test -f /etc/newrelic-super-agent/.nr-cli
456456
cmds:
457457
- |
458458
if [ "{{.NEW_RELIC_SUPER_AGENT_FLEET_ENABLED}}" = "false" ]; then
@@ -484,8 +484,8 @@ install:
484484
fi
485485
486486
config_super_agent_auth:
487-
status:
488-
- test -f /etc/newrelic-super-agent/.nr-cli
487+
status:
488+
- test -f /etc/newrelic-super-agent/.nr-cli
489489
cmds:
490490
- |
491491
if [ "{{.NEW_RELIC_SUPER_AGENT_FLEET_ENABLED}}" != "false" ] && [ "{{ .NEW_RELIC_ORGANIZATION }}" != "" ]; then
@@ -579,8 +579,8 @@ install:
579579
fi
580580
581581
config_host_monitoring:
582-
status:
583-
- test -f /etc/newrelic-super-agent/.nr-cli
582+
status:
583+
- test -f /etc/newrelic-super-agent/.nr-cli
584584
cmds:
585585
- |
586586
if [ "{{.NEW_RELIC_SUPER_AGENT_HOST_MONITORING_SOURCE}}" = "otel" ]; then
@@ -607,21 +607,45 @@ install:
607607
fi
608608
fi
609609
610-
assert_super_agent_started:
610+
assert_super_agent_status_ok:
611611
cmds:
612612
- |
613-
# Ensure super agent has enough time to start
614-
sleep 10
615-
IS_AGENT_INSTALLED=$(sudo ps aux | grep newrelic-super-agent | grep -v grep | wc -l)
616-
if [ $IS_AGENT_INSTALLED -eq 0 ] ; then
617-
echo "The newrelic super agent has not started after installing. Please try again later, or see our documentation for installing manually https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/install-configure/install-new-relic" >&2
618-
619-
if [ {{.IS_SYSTEMCTL}} -gt 0 ]; then
620-
journalctl -u newrelic-super-agent --no-pager
613+
MAX_RETRIES=150
614+
TRIES=0
615+
echo "Running agent status check attempt..."
616+
# wait for status endpoint to be ready
617+
while [ $TRIES -lt $MAX_RETRIES ]; do
618+
((TRIES++))
619+
statusCheckOutput=$(curl -s http://localhost:51200/status)
620+
if [ -z "$statusCheckOutput" ]; then
621+
# so jq doesn't fail if empty
622+
statusCheckOutput="{}"
621623
fi
622-
623-
exit 31
624-
fi
624+
STATUS=$(echo $statusCheckOutput | /usr/local/bin/newrelic utils jq '.super_agent.healthy')
625+
if [ "$STATUS" == "true" ]; then
626+
echo "Agent status check ok."
627+
break
628+
else
629+
if [ "$TRIES" -eq "$MAX_RETRIES" ]; then
630+
# Process-based validation attempt
631+
IS_AGENT_INSTALLED=$(ps aux | grep newrelic-super-agent | grep -v grep | wc -l)
632+
if [ $IS_AGENT_INSTALLED -gt 0 ] ; then
633+
echo "detected newrelic-super-agent process running"
634+
exit 0
635+
fi
636+
637+
echo "New Relic Agent Control has not started after installing. Please try again later, or see our documentation for installing manually https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/install-configure/install-new-relic" >&2
638+
639+
if [ {{.IS_SYSTEMCTL}} -gt 0 ]; then
640+
journalctl -u newrelic-super-agent --no-pager
641+
fi
642+
643+
exit 31
644+
fi
645+
fi
646+
647+
sleep 2
648+
done
625649
626650
signal_recipe_applied:
627651
cmds:
@@ -630,4 +654,4 @@ install:
630654
631655
post_install:
632656
info: |2
633-
⚙️ The New Relic Super Agent configuration file can be found in /etc/newrelic-super-agent/config.yaml
657+
⚙️ New Relic Agent Control configuration file can be found in /etc/newrelic-super-agent/config.yaml

0 commit comments

Comments
 (0)