Skip to content

Commit

Permalink
USM: enable Go TLS monitoring by default (#31064)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yumasi authored Nov 28, 2024
1 parent 83246bd commit a16fd69
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 20 deletions.
1 change: 1 addition & 0 deletions cmd/system-probe/config/adjust_usm.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func adjustUSM(cfg model.Config) {
deprecateBool(cfg, netNS("enable_http_monitoring"), smNS("enable_http_monitoring"))
deprecateBool(cfg, netNS("enable_https_monitoring"), smNS("tls", "native", "enabled"))
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"))
deprecateInt64(cfg, netNS("max_tracked_http_connections"), smNS("max_tracked_http_connections"))
applyDefault(cfg, smNS("max_tracked_http_connections"), 1024)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func TestFetchSystemProbeAgent(t *testing.T) {
assert.False(t, ia.data["feature_usm_redis_enabled"].(bool))
assert.False(t, ia.data["feature_usm_http2_enabled"].(bool))
assert.True(t, ia.data["feature_usm_istio_enabled"].(bool))
assert.False(t, ia.data["feature_usm_go_tls_enabled"].(bool))
assert.True(t, ia.data["feature_usm_go_tls_enabled"].(bool))
assert.False(t, ia.data["feature_discovery_enabled"].(bool))
assert.False(t, ia.data["feature_tcp_queue_length_enabled"].(bool))
assert.False(t, ia.data["feature_oom_kill_enabled"].(bool))
Expand Down
37 changes: 22 additions & 15 deletions pkg/network/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1464,34 +1464,34 @@ func TestUSMTLSNativeEnabled(t *testing.T) {
func TestUSMTLSGoEnabled(t *testing.T) {
t.Run("via deprecated YAML", func(t *testing.T) {
mockSystemProbe := mock.NewSystemProbe(t)
mockSystemProbe.SetWithoutSource("service_monitoring_config.enable_go_tls_support", true)
mockSystemProbe.SetWithoutSource("service_monitoring_config.enable_go_tls_support", false)
cfg := New()

require.True(t, cfg.EnableGoTLSSupport)
require.False(t, cfg.EnableGoTLSSupport)
})

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

require.True(t, cfg.EnableGoTLSSupport)
require.False(t, cfg.EnableGoTLSSupport)
})

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

require.True(t, cfg.EnableGoTLSSupport)
require.False(t, cfg.EnableGoTLSSupport)
})

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

require.True(t, cfg.EnableGoTLSSupport)
require.False(t, cfg.EnableGoTLSSupport)
})

t.Run("Deprecated is enabled, new is disabled", func(t *testing.T) {
Expand All @@ -1512,22 +1512,29 @@ func TestUSMTLSGoEnabled(t *testing.T) {
require.True(t, cfg.EnableGoTLSSupport)
})

t.Run("Both enabled", func(t *testing.T) {
t.Run("Both disabled", func(t *testing.T) {
mock.NewSystemProbe(t)
t.Setenv("DD_SERVICE_MONITORING_CONFIG_ENABLE_GO_TLS_SUPPORT", "true")
t.Setenv("DD_SERVICE_MONITORING_CONFIG_TLS_GO_ENABLED", "true")
t.Setenv("DD_SERVICE_MONITORING_CONFIG_ENABLE_GO_TLS_SUPPORT", "false")
t.Setenv("DD_SERVICE_MONITORING_CONFIG_TLS_GO_ENABLED", "false")
cfg := New()

require.True(t, cfg.EnableGoTLSSupport)
require.False(t, cfg.EnableGoTLSSupport)
})

t.Run("Not enabled", func(t *testing.T) {
mock.NewSystemProbe(t)
t.Run("Deprecated is disabled takes precedence over default", func(t *testing.T) {
mockSystemProbe := mock.NewSystemProbe(t)
mockSystemProbe.SetWithoutSource("service_monitoring_config.enable_go_tls_support", false)
cfg := New()

// Default value.
require.False(t, cfg.EnableGoTLSSupport)
})

t.Run("Enabled by default", func(t *testing.T) {
mock.NewSystemProbe(t)
cfg := New()

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

func TestUSMTLSGoExcludeSelf(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions pkg/network/usm/kafka_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1622,10 +1622,8 @@ func getDefaultTestConfiguration(tls bool) *config.Config {
cfg := config.New()
cfg.EnableKafkaMonitoring = true
cfg.MaxTrackedConnections = 1000
if tls {
cfg.EnableGoTLSSupport = true
cfg.GoTLSExcludeSelf = true
}
cfg.EnableGoTLSSupport = tls
cfg.GoTLSExcludeSelf = tls
return cfg
}

Expand Down Expand Up @@ -1727,6 +1725,7 @@ func TestLoadKafkaBinary(t *testing.T) {
func loadKafkaBinary(t *testing.T, debug bool) {
cfg := config.New()
// We don't have a way of enabling kafka without http at the moment
cfg.EnableGoTLSSupport = false
cfg.EnableKafkaMonitoring = true
cfg.MaxTrackedConnections = 1000
cfg.BPFDebug = debug
Expand Down
1 change: 1 addition & 0 deletions pkg/network/usm/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestMonitorProtocolFail(t *testing.T) {
patchProtocolMock(t, tt.spec)

cfg := config.New()
cfg.EnableGoTLSSupport = false
cfg.EnableHTTPMonitoring = true
cfg.EnableIstioMonitoring = false

Expand Down
4 changes: 4 additions & 0 deletions pkg/network/usm/monitor_tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (s *tlsSuite) TestHTTPSViaLibraryIntegration() {
t := s.T()

cfg := config.New()
cfg.EnableGoTLSSupport = false
cfg.EnableHTTPMonitoring = true
cfg.EnableNativeTLSMonitoring = true
/* enable protocol classification : TLS */
Expand Down Expand Up @@ -284,6 +285,7 @@ func (s *tlsSuite) TestOpenSSLVersions() {
t := s.T()

cfg := config.New()
cfg.EnableGoTLSSupport = false
cfg.EnableNativeTLSMonitoring = true
cfg.EnableHTTPMonitoring = true
usmMonitor := setupUSMTLSMonitor(t, cfg)
Expand Down Expand Up @@ -343,6 +345,7 @@ func (s *tlsSuite) TestOpenSSLVersionsSlowStart() {
t := s.T()

cfg := config.New()
cfg.EnableGoTLSSupport = false
cfg.EnableNativeTLSMonitoring = true
cfg.EnableHTTPMonitoring = true

Expand Down Expand Up @@ -902,6 +905,7 @@ func (s *tlsSuite) TestNodeJSTLS() {
require.NoError(t, err)

cfg := config.New()
cfg.EnableGoTLSSupport = false
cfg.EnableHTTPMonitoring = true
cfg.EnableNodeJSMonitoring = true

Expand Down
1 change: 1 addition & 0 deletions pkg/network/usm/tests/tracer_usm_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func (s *USMSuite) TestIgnoreTLSClassificationIfApplicationProtocolWasDetected()
t := s.T()
cfg := tracertestutil.Config()
cfg.ServiceMonitoringEnabled = true
cfg.EnableGoTLSSupport = false
// USM cannot be enabled without a protocol.
cfg.EnableHTTPMonitoring = true
cfg.ProtocolClassificationEnabled = true
Expand Down
1 change: 1 addition & 0 deletions pkg/network/usm/usm_http2_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ func (s *usmHTTP2Suite) TestRawHuffmanEncoding() {
func TestHTTP2InFlightMapCleaner(t *testing.T) {
skipIfKernelNotSupported(t)
cfg := config.New()
cfg.EnableGoTLSSupport = false
cfg.EnableIstioMonitoring = false
cfg.EnableHTTP2Monitoring = true
cfg.HTTP2DynamicTableMapCleanerInterval = 5 * time.Second
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
features:
- |
USM now monitors TLS traffic encrypted with Go TLS by default.
To disable this feature, set the `service_monitoring_config.tls.go.enabled`
configuration option to false.

0 comments on commit a16fd69

Please sign in to comment.