Skip to content

Commit 1e38d55

Browse files
committed
do not start/restart Agent service if experiment is running
1 parent 5c225cb commit 1e38d55

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

manifests/service.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@
1616
require => Package[$datadog_agent::params::package_name],
1717
}
1818
} else {
19+
# If `datadog-agent-exp` is active, skip service actions and exit early
20+
$exp_guard_cmd = 'if command -v systemctl >/dev/null 2>&1; then systemctl is-active --quiet datadog-agent-exp && exit 0; fi; if command -v service >/dev/null 2>&1; then service datadog-agent-exp status >/dev/null 2>&1 && exit 0; fi; pgrep -f datadog-packages/datadog-agent/experiment/bin/agent/agent >/dev/null 2>&1 && exit 0;'
21+
1922
if $service_provider {
2023
service { $datadog_agent::params::service_name:
2124
ensure => $service_ensure,
2225
enable => $service_enable,
2326
provider => $service_provider,
2427
hasstatus => false,
2528
pattern => 'dd-agent',
29+
# Avoid starting the Agent if a remote update is in progress (exp guard cmd terminates the whole command)
30+
start => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl start datadog-agent 2>/dev/null || service datadog-agent start 2>/dev/null || /bin/true"],
31+
# Avoid restarting the Agent if a remote update is in progress (exp guard cmd terminates the whole command)
32+
restart => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl restart datadog-agent 2>/dev/null || service datadog-agent restart 2>/dev/null || /bin/true"],
2633
require => Package[$agent_flavor],
2734
}
2835
} else {
@@ -31,6 +38,10 @@
3138
enable => $service_enable,
3239
hasstatus => false,
3340
pattern => 'dd-agent',
41+
# Avoid starting the Agent if a remote update is in progress (exp guard cmd terminates the whole command)
42+
start => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl start datadog-agent 2>/dev/null || service datadog-agent start 2>/dev/null || /bin/true"],
43+
# Avoid restarting the Agent if a remote update is in progress (exp guard cmd terminates the whole command)
44+
restart => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl restart datadog-agent 2>/dev/null || service datadog-agent restart 2>/dev/null || /bin/true"],
3445
require => Package[$agent_flavor],
3546
}
3647
}

0 commit comments

Comments
 (0)