Skip to content

Commit

Permalink
usm: config: Default USM configuration should not warn about using ne…
Browse files Browse the repository at this point in the history
…twork_config.enable_https_monitoring (DataDog#31639)
  • Loading branch information
guyarb authored Dec 2, 2024
1 parent 12bde50 commit 066618a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cmd/system-probe/config/adjust_usm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const (

func adjustUSM(cfg model.Config) {
if cfg.GetBool(smNS("enabled")) {
applyDefault(cfg, netNS("enable_https_monitoring"), true)
applyDefault(cfg, spNS("enable_runtime_compiler"), true)
applyDefault(cfg, spNS("enable_kernel_header_download"), true)

Expand All @@ -29,6 +28,7 @@ func adjustUSM(cfg model.Config) {
deprecateBool(cfg, netNS("enable_http_monitoring"), smNS("enable_http_monitoring"))
applyDefault(cfg, smNS("enable_http_monitoring"), true)
deprecateBool(cfg, netNS("enable_https_monitoring"), smNS("tls", "native", "enabled"))
applyDefault(cfg, smNS("tls", "native", "enabled"), true)
deprecateBool(cfg, smNS("enable_go_tls_support"), smNS("tls", "go", "enabled"))
applyDefault(cfg, smNS("tls", "go", "enabled"), true)
deprecateGeneric(cfg, netNS("http_replace_rules"), smNS("http_replace_rules"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func TestFetchSystemProbeAgent(t *testing.T) {
assert.True(t, ia.data["feature_cws_remote_config_enabled"].(bool))
assert.False(t, ia.data["feature_networks_enabled"].(bool))
assert.True(t, ia.data["feature_networks_http_enabled"].(bool))
assert.False(t, ia.data["feature_networks_https_enabled"].(bool))
assert.True(t, ia.data["feature_networks_https_enabled"].(bool))
assert.False(t, ia.data["feature_usm_enabled"].(bool))
assert.False(t, ia.data["feature_usm_kafka_enabled"].(bool))
assert.False(t, ia.data["feature_usm_postgres_enabled"].(bool))
Expand Down
37 changes: 18 additions & 19 deletions pkg/network/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,36 +1393,43 @@ func TestMaxUSMConcurrentRequests(t *testing.T) {
}

func TestUSMTLSNativeEnabled(t *testing.T) {
t.Run("Default", func(t *testing.T) {
mock.NewSystemProbe(t)
cfg := New()

assert.True(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("via deprecated YAML", func(t *testing.T) {
mockSystemProbe := mock.NewSystemProbe(t)
mockSystemProbe.SetWithoutSource("network_config.enable_https_monitoring", true)
mockSystemProbe.SetWithoutSource("network_config.enable_https_monitoring", false)
cfg := New()

require.True(t, cfg.EnableNativeTLSMonitoring)
assert.False(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("via deprecated ENV variable", func(t *testing.T) {
mock.NewSystemProbe(t)
t.Setenv("DD_SYSTEM_PROBE_NETWORK_ENABLE_HTTPS_MONITORING", "true")
t.Setenv("DD_SYSTEM_PROBE_NETWORK_ENABLE_HTTPS_MONITORING", "false")
cfg := New()

require.True(t, cfg.EnableNativeTLSMonitoring)
assert.False(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("via YAML", func(t *testing.T) {
mockSystemProbe := mock.NewSystemProbe(t)
mockSystemProbe.SetWithoutSource("service_monitoring_config.tls.native.enabled", true)
mockSystemProbe.SetWithoutSource("service_monitoring_config.tls.native.enabled", false)
cfg := New()

require.True(t, cfg.EnableNativeTLSMonitoring)
assert.False(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("via ENV variable", func(t *testing.T) {
mock.NewSystemProbe(t)
t.Setenv("DD_SERVICE_MONITORING_CONFIG_TLS_NATIVE_ENABLED", "true")
t.Setenv("DD_SERVICE_MONITORING_CONFIG_TLS_NATIVE_ENABLED", "false")
cfg := New()

require.True(t, cfg.EnableNativeTLSMonitoring)
assert.False(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("Deprecated is enabled, new is disabled", func(t *testing.T) {
Expand All @@ -1431,7 +1438,7 @@ func TestUSMTLSNativeEnabled(t *testing.T) {
t.Setenv("DD_SERVICE_MONITORING_CONFIG_TLS_NATIVE_ENABLED", "false")
cfg := New()

require.False(t, cfg.EnableNativeTLSMonitoring)
assert.False(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("Deprecated is disabled, new is enabled", func(t *testing.T) {
Expand All @@ -1440,7 +1447,7 @@ func TestUSMTLSNativeEnabled(t *testing.T) {
t.Setenv("DD_SERVICE_MONITORING_CONFIG_TLS_NATIVE_ENABLED", "true")
cfg := New()

require.True(t, cfg.EnableNativeTLSMonitoring)
assert.True(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("Both enabled", func(t *testing.T) {
Expand All @@ -1449,15 +1456,7 @@ func TestUSMTLSNativeEnabled(t *testing.T) {
t.Setenv("DD_SERVICE_MONITORING_CONFIG_TLS_NATIVE_ENABLED", "true")
cfg := New()

require.True(t, cfg.EnableNativeTLSMonitoring)
})

t.Run("Not enabled", func(t *testing.T) {
mock.NewSystemProbe(t)
cfg := New()

// Default value.
require.False(t, cfg.EnableNativeTLSMonitoring)
assert.True(t, cfg.EnableNativeTLSMonitoring)
})
}

Expand Down

0 comments on commit 066618a

Please sign in to comment.