diff --git a/cmd/system-probe/modules/eventmonitor.go b/cmd/system-probe/modules/eventmonitor.go index e38b237c74f3..132be172b733 100644 --- a/cmd/system-probe/modules/eventmonitor.go +++ b/cmd/system-probe/modules/eventmonitor.go @@ -133,7 +133,11 @@ func createEventMonitorModule(_ *sysconfigtypes.Config, deps module.FactoryDepen } gpucfg := gpuconfig.New() - if gpucfg.Enabled { + // Only the eBPF probes consume these events, so skip the consumer entirely + // when they are disabled. Kept in sync with the module gate in + // pkg/system-probe/config, which does not enable the event monitor for GPU + // monitoring unless the probes are enabled too. + if gpucfg.Enabled && gpucfg.EnableEBPFProbes { err := createGPUProcessEventConsumer(evm) if err != nil { return nil, fmt.Errorf("cannot create event consumer for GPU: %w", err) diff --git a/pkg/system-probe/config/config.go b/pkg/system-probe/config/config.go index c7d5183123cf..5572300e4c67 100644 --- a/pkg/system-probe/config/config.go +++ b/pkg/system-probe/config/config.go @@ -127,6 +127,9 @@ func load() (*types.Config, error) { eudmEnabled := coreCfg.GetString("infrastructure_mode") == "end_user_device" csmEnabled := cfg.GetBool(secNS("enabled")) gpuEnabled := cfg.GetBool(gpuNS("enabled")) + // The GPU module only consumes process events when its eBPF probes are + // loaded, so the event monitor is only needed for that combination. + gpuEBPFProbesEnabled := gpuEnabled && cfg.GetBool(gpuNS("enable_ebpf_probes")) diEnabled := cfg.GetBool(diNS("enabled")) swEnabled := coreCfg.GetBool(swNS("enabled")) discoveryServiceMapEnabled := cfg.GetBool(discoveryNS("service_map", "enabled")) @@ -145,7 +148,7 @@ func load() (*types.Config, error) { coreCfg.GetBool("sbom.enrichment.usage.enabled") || (usmEnabled && cfg.GetBool(smNS("enable_event_stream"))) || (c.ModuleIsEnabled(NetworkTracerModule) && cfg.GetBool(evNS("network_process.enabled"))) || - gpuEnabled || + gpuEBPFProbesEnabled || diEnabled { c.EnabledModules[EventMonitorModule] = struct{}{} } diff --git a/pkg/system-probe/config/config_test.go b/pkg/system-probe/config/config_test.go index 52dcd63b62fa..ff482fa4b4f6 100644 --- a/pkg/system-probe/config/config_test.go +++ b/pkg/system-probe/config/config_test.go @@ -23,6 +23,7 @@ func TestEventMonitor(t *testing.T) { for i, tc := range []struct { cws, fim, networkEvents, gpu bool + gpuEBPFProbes bool usmEvents bool enabled bool }{ @@ -34,7 +35,11 @@ func TestEventMonitor(t *testing.T) { {cws: false, fim: true, networkEvents: true, enabled: true}, {cws: true, fim: false, networkEvents: true, enabled: true}, {cws: true, fim: true, networkEvents: true, enabled: true}, - {cws: false, fim: false, networkEvents: false, gpu: true, enabled: true}, + // GPU monitoring only needs the event monitor to feed its eBPF probes, + // so both settings have to be enabled for the module to be pulled in. + {cws: false, fim: false, networkEvents: false, gpu: true, gpuEBPFProbes: true, enabled: true}, + {cws: false, fim: false, networkEvents: false, gpu: true, gpuEBPFProbes: false, enabled: false}, + {cws: false, fim: false, networkEvents: false, gpu: false, gpuEBPFProbes: true, enabled: false}, {usmEvents: true, enabled: true}, } { t.Run(strconv.Itoa(i), func(t *testing.T) { @@ -44,6 +49,9 @@ func TestEventMonitor(t *testing.T) { t.Setenv("DD_SYSTEM_PROBE_EVENT_MONITORING_NETWORK_PROCESS_ENABLED", strconv.FormatBool(tc.networkEvents)) t.Setenv("DD_SYSTEM_PROBE_NETWORK_ENABLED", strconv.FormatBool(tc.networkEvents)) t.Setenv("DD_GPU_MONITORING_ENABLED", strconv.FormatBool(tc.gpu)) + // Set explicitly rather than relying on the default, which is + // subject to change as the eBPF probes are deprecated. + t.Setenv("DD_GPU_MONITORING_ENABLE_EBPF_PROBES", strconv.FormatBool(tc.gpuEBPFProbes)) t.Setenv("DD_SYSTEM_PROBE_SERVICE_MONITORING_ENABLED", strconv.FormatBool(tc.usmEvents)) t.Setenv("DD_SERVICE_MONITORING_CONFIG_ENABLE_EVENT_STREAM", strconv.FormatBool(tc.usmEvents))