Skip to content

Commit d85d303

Browse files
authored
[kafka] backward compatibility + fix process/apm default behavior (#395)
* [kafka] make it backward compatible * [metadata] updating metadata * [apm][process] these are opt-in options dont want to force those on anyone
1 parent 7f58ca5 commit d85d303

6 files changed

Lines changed: 43 additions & 62 deletions

File tree

manifests/init.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@
159159
# String. Default: empty
160160
# $apm_enabled
161161
# Boolean to enable or disable the trace agent
162-
# Boolean. Default: true
162+
# Boolean. Default: false
163163
# $apm_env
164164
# String defining the environment for the APM traces
165165
# String. Default: empty
166166
# $process_enabled
167167
# String to enable the process/container agent
168-
# Boolean. Default: true
168+
# Boolean. Default: false
169169
#
170170
# Actions:
171171
#
@@ -262,7 +262,7 @@
262262
$apm_enabled = $datadog_agent::params::apm_default_enabled,
263263
$apm_env = '',
264264
$process_enabled = $datadog_agent::params::process_default_enabled,
265-
Hash[String, Data] $agent6_extra_options = {},
265+
Hash[String[1], Data] $agent6_extra_options = {},
266266
$agent5_repo_uri = $datadog_agent::params::agent5_default_repo,
267267
$agent6_repo_uri = $datadog_agent::params::agent6_default_repo,
268268
$apt_release = $datadog_agent::params::apt_default_release,
@@ -493,7 +493,7 @@
493493
} else {
494494

495495
# lint:ignore:quoted_booleans
496-
$process_enabled_str = $process_enabled ? { true => 'true' , default => 'false' }
496+
$process_enabled_str = $process_enabled ? { true => 'true' , default => 'disabled' }
497497
# lint:endignore
498498
$base_extra_config = {
499499
'apm_config' => { 'apm_enabled' => $apm_enabled },

manifests/integrations/kafka.pp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,38 @@
5353
# }
5454
#
5555
class datadog_agent::integrations::kafka(
56-
$servers = [{'host' => 'localhost', 'port' => '9999'}]
56+
$host = 'localhost',
57+
Variant[String[1], Integer] $port = 9999,
58+
Optional[String[1]] $username = undef,
59+
Optional[String[1]] $password = undef,
60+
Optional[String[1]] $process_name_regex = undef,
61+
Optional[String[1]] $tools_jar_path = undef,
62+
Optional[String[1]] $java_bin_path = undef,
63+
Optional[String[1]] $trust_store_path = undef,
64+
Optional[String[1]] $trust_store_password = undef,
65+
Optional[Hash[String[1], String[1]]] $tags = undef,
66+
Optional[Array[Hash[String[1], Data]]] $instances = undef,
5767
) inherits datadog_agent::params {
5868
include datadog_agent
5969

60-
validate_array($servers)
70+
if !$instances and $host and $port {
71+
$servers = [{
72+
'host' => $host,
73+
'port' => $port,
74+
'username' => $username,
75+
'password' => $password,
76+
'process_name_regex' => $process_name_regex,
77+
'tools_jar_path' => $tools_jar_path,
78+
'java_bin_path' => $java_bin_path,
79+
'trust_store_path' => $trust_store_path,
80+
'trust_store_password' => $trust_store_password,
81+
'tags' => $tags,
82+
}]
83+
} elsif !$instances{
84+
$servers = []
85+
} else {
86+
$servers = $instances
87+
}
6188

6289
file { "${datadog_agent::params::conf_dir}/kafka.yaml":
6390
ensure => file,
@@ -68,4 +95,4 @@
6895
require => Package[$datadog_agent::params::package_name],
6996
notify => Service[$datadog_agent::params::service_name],
7097
}
71-
}
98+
}

manifests/params.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
$dogapi_version = 'installed'
2727
$conf_dir_purge = false
2828
$apt_default_release = 'stable'
29-
$apm_default_enabled = true
30-
$process_default_enabled = true
29+
$apm_default_enabled = false
30+
$process_default_enabled = false
3131

3232
case $::operatingsystem {
3333
'Ubuntu','Debian' : {

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"requirements": [
3838
{
3939
"name": "pe",
40-
"version_requirement": "2016.4.x"
40+
"version_requirement": ">=2016.4.x"
4141
},
4242
{
4343
"name": "puppet",

spec/classes/datadog_agent_integrations_kafka_spec.rb

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
context 'with one kafka broker' do
3030
let(:params) {{
31-
servers: [
31+
instances: [
3232
{
3333
'host' => 'localhost',
3434
'port' => '9997',
@@ -42,7 +42,7 @@
4242

4343
context 'with two kafka brokers' do
4444
let(:params) {{
45-
servers: [
45+
instances: [
4646
{
4747
'host' => 'localhost',
4848
'port' => '9997',
@@ -63,7 +63,7 @@
6363

6464
context 'one kafka broker all options' do
6565
let(:params) {{
66-
servers: [
66+
instances: [
6767
{
6868
'host' => 'localhost',
6969
'port' => '9997',
@@ -82,50 +82,4 @@
8282

8383
it { should contain_file(conf_file).with_content(%r{host: localhost\s+port: 9997\s+tags:\s+- kafka:broker\s+- tag1:value1\s+user: username\s+password: password\s+process_name_regex: regex\s+tools_jar_path: tools.jar\s+name: kafka_instance\s+java_bin_path: /path/to/java\s+trust_store_path: /path/to/trustStore.jks\s+trust_store_password: password}) }
8484
end
85-
=begin
86-
context 'with multiple mongos' do
87-
let(:params) {{
88-
servers: [
89-
{
90-
'host' => '127.0.0.1',
91-
'port' => '34567',
92-
'tags' => %w{foo bar},
93-
},
94-
{
95-
'host' => '127.0.0.2',
96-
'port' => '45678',
97-
'tags' => %w{baz bat},
98-
}
99-
]
100-
}}
101-
it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:34567/\s+tags:\s+- foo\s+- bar}) }
102-
it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.2:45678/\s+tags:\s+- baz\s+- bat}) }
103-
it { should contain_file(conf_file).with_content(%r{server:.*127.0.0.1.*server:.*127.0.0.2}m) }
104-
end
105-
106-
context 'without tags' do
107-
let(:params) {{
108-
servers: [
109-
{
110-
'host' => '127.0.0.1',
111-
'port' => '12345',
112-
}
113-
]
114-
}}
115-
116-
end
117-
118-
context 'weird tags' do
119-
let(:params) {{
120-
servers: [
121-
{
122-
'host' => '127.0.0.1',
123-
'port' => '56789',
124-
'tags' => 'word'
125-
}
126-
]
127-
}}
128-
it { should_not compile }
129-
end
130-
=end
13185
end

spec/classes/datadog_agent_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210

211211
context 'for APM' do
212212
it { should contain_concat__fragment('datadog footer').with(
213-
'content' => /^apm_enabled: true\n/,
213+
'content' => /^apm_enabled: false\n/,
214214
)}
215215
end
216216

@@ -840,13 +840,13 @@
840840
'content' => /^apm_config:\n/,
841841
)}
842842
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
843-
'content' => /^\ \ apm_enabled: true\n/,
843+
'content' => /^\ \ apm_enabled: false\n/,
844844
)}
845845
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
846846
'content' => /^process_config:\n/,
847847
)}
848848
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
849-
'content' => /^\ \ process_enabled: 'true'\n/,
849+
'content' => /^\ \ process_enabled: disabled\n/,
850850
)}
851851
end
852852
end

0 commit comments

Comments
 (0)