From 41dc41552211b624e4be4315484e1909ffb324df Mon Sep 17 00:00:00 2001 From: Guy Arbitman Date: Mon, 18 Nov 2024 08:21:40 +0200 Subject: [PATCH 1/4] [usm] add module name to debugger (#31003) --- cmd/system-probe/modules/network_tracer.go | 11 +- pkg/ebpf/uprobes/attacher.go | 6 +- pkg/ebpf/uprobes/attacher_test.go | 42 +++-- pkg/gpu/probe.go | 3 +- pkg/gpu/probe_test.go | 14 +- pkg/network/usm/consts/consts.go | 12 ++ pkg/network/usm/ebpf_gotls.go | 3 +- pkg/network/usm/ebpf_ssl_test.go | 5 +- pkg/network/usm/istio.go | 5 +- pkg/network/usm/kafka_monitor_test.go | 7 +- pkg/network/usm/monitor.go | 5 +- pkg/network/usm/monitor_tls_test.go | 19 +- pkg/network/usm/nodejs.go | 3 +- pkg/network/usm/postgres_monitor_test.go | 3 +- pkg/network/usm/sharedlibraries/watcher.go | 5 +- .../usm/tests/tracer_usm_linux_test.go | 9 +- pkg/network/usm/usm_grpc_monitor_test.go | 5 +- pkg/network/usm/usm_http2_monitor_test.go | 17 +- pkg/network/usm/utils/debugger.go | 117 +++++++----- pkg/network/usm/utils/debugger_test.go | 170 ++++++++++++++++++ pkg/network/usm/utils/debugger_testutils.go | 25 +-- pkg/network/usm/utils/debugger_windows.go | 40 +++-- pkg/network/usm/utils/file_registry.go | 4 +- pkg/network/usm/utils/file_registry_test.go | 12 +- 24 files changed, 395 insertions(+), 147 deletions(-) create mode 100644 pkg/network/usm/consts/consts.go create mode 100644 pkg/network/usm/utils/debugger_test.go diff --git a/cmd/system-probe/modules/network_tracer.go b/cmd/system-probe/modules/network_tracer.go index b605a3f0e99c30..772210a52376e0 100644 --- a/cmd/system-probe/modules/network_tracer.go +++ b/cmd/system-probe/modules/network_tracer.go @@ -34,6 +34,7 @@ import ( redisdebugging "github.com/DataDog/datadog-agent/pkg/network/protocols/redis/debugging" "github.com/DataDog/datadog-agent/pkg/network/protocols/telemetry" "github.com/DataDog/datadog-agent/pkg/network/tracer" + usmconsts "github.com/DataDog/datadog-agent/pkg/network/usm/consts" usm "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/process/statsd" "github.com/DataDog/datadog-agent/pkg/util/log" @@ -293,11 +294,11 @@ func (nt *networkTracer) Register(httpMux *module.Router) error { }) httpMux.HandleFunc("/debug/usm_telemetry", telemetry.Handler) - httpMux.HandleFunc("/debug/usm/traced_programs", usm.TracedProgramsEndpoint) - httpMux.HandleFunc("/debug/usm/blocked_processes", usm.BlockedPathIDEndpoint) - httpMux.HandleFunc("/debug/usm/clear_blocked", usm.ClearBlockedEndpoint) - httpMux.HandleFunc("/debug/usm/attach-pid", usm.AttachPIDEndpoint) - httpMux.HandleFunc("/debug/usm/detach-pid", usm.DetachPIDEndpoint) + httpMux.HandleFunc("/debug/usm/traced_programs", usm.GetTracedProgramsEndpoint(usmconsts.USMModuleName)) + httpMux.HandleFunc("/debug/usm/blocked_processes", usm.GetBlockedPathIDEndpoint(usmconsts.USMModuleName)) + httpMux.HandleFunc("/debug/usm/clear_blocked", usm.GetClearBlockedEndpoint(usmconsts.USMModuleName)) + httpMux.HandleFunc("/debug/usm/attach-pid", usm.GetAttachPIDEndpoint(usmconsts.USMModuleName)) + httpMux.HandleFunc("/debug/usm/detach-pid", usm.GetDetachPIDEndpoint(usmconsts.USMModuleName)) // Convenience logging if nothing has made any requests to the system-probe in some time, let's log something. // This should be helpful for customers + support to debug the underlying issue. diff --git a/pkg/ebpf/uprobes/attacher.go b/pkg/ebpf/uprobes/attacher.go index 0ddf21859c1ec4..f537b174cf6ebc 100644 --- a/pkg/ebpf/uprobes/attacher.go +++ b/pkg/ebpf/uprobes/attacher.go @@ -336,7 +336,7 @@ type UprobeAttacher struct { // way). // - The process monitor to be used to subscribe to process start and exit events. The lifecycle of the process monitor is managed by the caller, the attacher // will not stop the monitor when it stops. -func NewUprobeAttacher(name string, config AttacherConfig, mgr ProbeManager, onAttachCallback AttachCallback, inspector BinaryInspector, processMonitor ProcessMonitor) (*UprobeAttacher, error) { +func NewUprobeAttacher(moduleName, name string, config AttacherConfig, mgr ProbeManager, onAttachCallback AttachCallback, inspector BinaryInspector, processMonitor ProcessMonitor) (*UprobeAttacher, error) { config.SetDefaults() if err := config.Validate(); err != nil { @@ -346,7 +346,7 @@ func NewUprobeAttacher(name string, config AttacherConfig, mgr ProbeManager, onA ua := &UprobeAttacher{ name: name, config: config, - fileRegistry: utils.NewFileRegistry(name), + fileRegistry: utils.NewFileRegistry(moduleName, name), manager: mgr, onAttachCallback: onAttachCallback, pathToAttachedProbes: make(map[string][]manager.ProbeIdentificationPair), @@ -355,7 +355,7 @@ func NewUprobeAttacher(name string, config AttacherConfig, mgr ProbeManager, onA processMonitor: processMonitor, } - utils.AddAttacher(name, ua) + utils.AddAttacher(moduleName, name, ua) return ua, nil } diff --git a/pkg/ebpf/uprobes/attacher_test.go b/pkg/ebpf/uprobes/attacher_test.go index 73b290eba84435..dc06c6e1935525 100644 --- a/pkg/ebpf/uprobes/attacher_test.go +++ b/pkg/ebpf/uprobes/attacher_test.go @@ -38,8 +38,13 @@ import ( // === Tests +const ( + testModuleName = "mock-module" + testAttacherName = "mock" +) + func TestCanCreateAttacher(t *testing.T) { - ua, err := NewUprobeAttacher("mock", AttacherConfig{}, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, AttacherConfig{}, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) } @@ -51,7 +56,7 @@ func TestAttachPidExcludesInternal(t *testing.T) { ExcludeTargets: ExcludeInternal, ProcRoot: procRoot, } - ua, err := NewUprobeAttacher("mock", config, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -63,7 +68,7 @@ func TestAttachPidExcludesSelf(t *testing.T) { config := AttacherConfig{ ExcludeTargets: ExcludeSelf, } - ua, err := NewUprobeAttacher("mock", config, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -77,7 +82,7 @@ func TestGetExecutablePath(t *testing.T) { config := AttacherConfig{ ProcRoot: procRoot, } - ua, err := NewUprobeAttacher("mock", config, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -120,7 +125,7 @@ func TestGetLibrariesFromMapsFile(t *testing.T) { config := AttacherConfig{ ProcRoot: procRoot, } - ua, err := NewUprobeAttacher("mock", config, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -132,7 +137,7 @@ func TestGetLibrariesFromMapsFile(t *testing.T) { } func TestComputeRequestedSymbols(t *testing.T) { - ua, err := NewUprobeAttacher("mock", AttacherConfig{}, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, AttacherConfig{}, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -204,7 +209,7 @@ func TestComputeRequestedSymbols(t *testing.T) { } func TestStartAndStopWithoutLibraryWatcher(t *testing.T) { - ua, err := NewUprobeAttacher("mock", AttacherConfig{}, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, AttacherConfig{}, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -223,7 +228,7 @@ func TestStartAndStopWithLibraryWatcher(t *testing.T) { } rules := []*AttachRule{{LibraryNameRegex: regexp.MustCompile(`libssl.so`), Targets: AttachToSharedLibraries}} - ua, err := NewUprobeAttacher("mock", AttacherConfig{Rules: rules, EbpfConfig: ebpfCfg}, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, AttacherConfig{Rules: rules, EbpfConfig: ebpfCfg}, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) require.True(t, ua.handlesLibraries()) @@ -283,7 +288,7 @@ func TestMonitor(t *testing.T) { }}, EbpfConfig: ebpfCfg, } - ua, err := NewUprobeAttacher("mock", config, &MockManager{}, nil, nil, procMon) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, &MockManager{}, nil, nil, procMon) require.NoError(t, err) require.NotNil(t, ua) @@ -305,8 +310,9 @@ func TestMonitor(t *testing.T) { return methodHasBeenCalledAtLeastTimes(mockRegistry, "Register", 2) }, 1500*time.Millisecond, 10*time.Millisecond, "received calls %v", mockRegistry.Calls) - mockRegistry.AssertCalled(t, "Register", lib, uint32(cmd.Process.Pid), mock.Anything, mock.Anything, mock.Anything) mockRegistry.AssertCalled(t, "Register", cmd.Path, uint32(cmd.Process.Pid), mock.Anything, mock.Anything, mock.Anything) + mockRegistry.AssertCalled(t, "Register", lib, uint32(cmd.Process.Pid), mock.Anything, mock.Anything, mock.Anything) + } func TestSync(t *testing.T) { @@ -333,7 +339,7 @@ func TestSync(t *testing.T) { EnablePeriodicScanNewProcesses: true, } - ua, err := NewUprobeAttacher("mock", config, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(tt, err) require.NotNil(tt, ua) @@ -365,7 +371,7 @@ func TestSync(t *testing.T) { EnablePeriodicScanNewProcesses: true, } - ua, err := NewUprobeAttacher("mock", config, &MockManager{}, nil, nil, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, &MockManager{}, nil, nil, newMockProcessMonitor()) require.NoError(tt, err) require.NotNil(tt, ua) @@ -441,7 +447,7 @@ func TestAttachToBinaryAndDetach(t *testing.T) { mockMan := &MockManager{} inspector := &MockBinaryInspector{} - ua, err := NewUprobeAttacher("mock", config, mockMan, nil, inspector, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, mockMan, nil, inspector, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -502,7 +508,7 @@ func TestAttachToBinaryAtReturnLocation(t *testing.T) { mockMan := &MockManager{} inspector := &MockBinaryInspector{} - ua, err := NewUprobeAttacher("mock", config, mockMan, nil, inspector, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, mockMan, nil, inspector, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) @@ -583,7 +589,7 @@ func TestAttachToLibrariesOfPid(t *testing.T) { mockMan := &MockManager{} inspector := &MockBinaryInspector{} registry := &MockFileRegistry{} - ua, err := NewUprobeAttacher("mock", config, mockMan, nil, inspector, newMockProcessMonitor()) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, config, mockMan, nil, inspector, newMockProcessMonitor()) require.NoError(t, err) require.NotNil(t, ua) ua.fileRegistry = registry @@ -700,7 +706,7 @@ func TestUprobeAttacher(t *testing.T) { attachedProbes = append(attachedProbes, attachedProbe{probe: probe, fpath: fpath}) } - ua, err := NewUprobeAttacher("test", attacherCfg, &mgr, callback, &NativeBinaryInspector{}, procMon) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, attacherCfg, &mgr, callback, &NativeBinaryInspector{}, procMon) require.NoError(t, err) require.NotNil(t, ua) @@ -808,7 +814,7 @@ func (s *SharedLibrarySuite) TestSingleFile() { PerformInitialScan: false, } - ua, err := NewUprobeAttacher("test", attachCfg, &MockManager{}, nil, nil, s.procMonitor) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, attachCfg, &MockManager{}, nil, nil, s.procMonitor) require.NoError(t, err) mockRegistry := &MockFileRegistry{} @@ -885,7 +891,7 @@ func (s *SharedLibrarySuite) TestDetectionWithPIDAndRootNamespace() { EbpfConfig: ebpfCfg, } - ua, err := NewUprobeAttacher("test", attachCfg, &MockManager{}, nil, nil, s.procMonitor) + ua, err := NewUprobeAttacher(testModuleName, testAttacherName, attachCfg, &MockManager{}, nil, nil, s.procMonitor) require.NoError(t, err) mockRegistry := &MockFileRegistry{} diff --git a/pkg/gpu/probe.go b/pkg/gpu/probe.go index c8b6a19e76db93..d159cdc0d182a4 100644 --- a/pkg/gpu/probe.go +++ b/pkg/gpu/probe.go @@ -32,6 +32,7 @@ import ( const ( gpuAttacherName = "gpu" + gpuModuleName = gpuAttacherName // consumerChannelSize controls the size of the go channel that buffers ringbuffer // events (*ddebpf.RingBufferHandler). @@ -142,7 +143,7 @@ func NewProbe(cfg *config.Config, deps ProbeDependencies) (*Probe, error) { } } - p.attacher, err = uprobes.NewUprobeAttacher(gpuAttacherName, attachCfg, p.m, nil, &uprobes.NativeBinaryInspector{}, deps.ProcessMonitor) + p.attacher, err = uprobes.NewUprobeAttacher(gpuModuleName, gpuAttacherName, attachCfg, p.m, nil, &uprobes.NativeBinaryInspector{}, deps.ProcessMonitor) if err != nil { return nil, fmt.Errorf("error creating uprobes attacher: %w", err) } diff --git a/pkg/gpu/probe_test.go b/pkg/gpu/probe_test.go index d37bb8ffa68b6e..9739fc0eccd51b 100644 --- a/pkg/gpu/probe_test.go +++ b/pkg/gpu/probe_test.go @@ -74,7 +74,7 @@ func (s *probeTestSuite) TestCanReceiveEvents() { probe := s.getProbe() cmd := testutil.RunSample(t, testutil.CudaSample) - utils.WaitForProgramsToBeTraced(t, gpuAttacherName, cmd.Process.Pid, utils.ManualTracingFallbackDisabled) + utils.WaitForProgramsToBeTraced(t, gpuModuleName, gpuAttacherName, cmd.Process.Pid, utils.ManualTracingFallbackDisabled) var handlerStream, handlerGlobal *StreamHandler require.Eventually(t, func() bool { @@ -117,12 +117,12 @@ func (s *probeTestSuite) TestCanGenerateStats() { cmd := testutil.RunSample(t, testutil.CudaSample) - utils.WaitForProgramsToBeTraced(t, gpuAttacherName, cmd.Process.Pid, utils.ManualTracingFallbackDisabled) + utils.WaitForProgramsToBeTraced(t, gpuModuleName, gpuAttacherName, cmd.Process.Pid, utils.ManualTracingFallbackDisabled) // Wait until the process finishes and we can get the stats. Run this instead of waiting for the process to finish // so that we can time out correctly require.Eventually(t, func() bool { - return !utils.IsProgramTraced(gpuAttacherName, cmd.Process.Pid) + return !utils.IsProgramTraced(gpuModuleName, gpuAttacherName, cmd.Process.Pid) }, 20*time.Second, 500*time.Millisecond, "process not stopped") stats, err := probe.GetAndFlush() @@ -153,12 +153,12 @@ func (s *probeTestSuite) TestMultiGPUSupport() { selectedGPU := testutil.GPUUUIDs[2] cmd := testutil.RunSampleWithArgs(t, testutil.CudaSample, sampleArgs) - utils.WaitForProgramsToBeTraced(t, gpuAttacherName, cmd.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, gpuModuleName, gpuAttacherName, cmd.Process.Pid, utils.ManualTracingFallbackEnabled) // Wait until the process finishes and we can get the stats. Run this instead of waiting for the process to finish // so that we can time out correctly require.Eventually(t, func() bool { - return !utils.IsProgramTraced(gpuAttacherName, cmd.Process.Pid) + return !utils.IsProgramTraced(gpuModuleName, gpuAttacherName, cmd.Process.Pid) }, 60*time.Second, 500*time.Millisecond, "process not stopped") stats, err := probe.GetAndFlush() @@ -184,12 +184,12 @@ func (s *probeTestSuite) TestDetectsContainer() { args.EndWaitTimeSec = 1 pid, cid := testutil.RunSampleInDockerWithArgs(t, testutil.CudaSample, testutil.MinimalDockerImage, args) - utils.WaitForProgramsToBeTraced(t, gpuAttacherName, pid, utils.ManualTracingFallbackDisabled) + utils.WaitForProgramsToBeTraced(t, gpuModuleName, gpuAttacherName, pid, utils.ManualTracingFallbackDisabled) // Wait until the process finishes and we can get the stats. Run this instead of waiting for the process to finish // so that we can time out correctly require.Eventually(t, func() bool { - return !utils.IsProgramTraced(gpuAttacherName, pid) + return !utils.IsProgramTraced(gpuModuleName, gpuAttacherName, pid) }, 20*time.Second, 500*time.Millisecond, "process not stopped") // Check that the stream handlers have the correct container ID assigned diff --git a/pkg/network/usm/consts/consts.go b/pkg/network/usm/consts/consts.go new file mode 100644 index 00000000000000..de7cfb06a464cc --- /dev/null +++ b/pkg/network/usm/consts/consts.go @@ -0,0 +1,12 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +// Package consts contains constants used by the USM package. +package consts + +const ( + // USMModuleName is the name of the USM module, that is being used for registering attachers. + USMModuleName = "usm" +) diff --git a/pkg/network/usm/ebpf_gotls.go b/pkg/network/usm/ebpf_gotls.go index a36d2ba399442b..ecbfd5ff68d779 100644 --- a/pkg/network/usm/ebpf_gotls.go +++ b/pkg/network/usm/ebpf_gotls.go @@ -24,6 +24,7 @@ import ( libtelemetry "github.com/DataDog/datadog-agent/pkg/network/protocols/telemetry" "github.com/DataDog/datadog-agent/pkg/network/usm/buildmode" usmconfig "github.com/DataDog/datadog-agent/pkg/network/usm/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/process/monitor" ) @@ -148,7 +149,7 @@ func newGoTLSProgramProtocolFactory(m *manager.Manager) protocols.ProtocolFactor } procMon := monitor.GetProcessMonitor() - attacher, err := uprobes.NewUprobeAttacher(GoTLSAttacherName, attacherCfg, m, nil, inspector, procMon) + attacher, err := uprobes.NewUprobeAttacher(consts.USMModuleName, GoTLSAttacherName, attacherCfg, m, nil, inspector, procMon) if err != nil { return nil, fmt.Errorf("cannot create uprobe attacher: %w", err) } diff --git a/pkg/network/usm/ebpf_ssl_test.go b/pkg/network/usm/ebpf_ssl_test.go index 3a1adf612b3abc..f94dde8fb31104 100644 --- a/pkg/network/usm/ebpf_ssl_test.go +++ b/pkg/network/usm/ebpf_ssl_test.go @@ -19,6 +19,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/network/config" "github.com/DataDog/datadog-agent/pkg/network/protocols/http/testutil" usmconfig "github.com/DataDog/datadog-agent/pkg/network/usm/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" fileopener "github.com/DataDog/datadog-agent/pkg/network/usm/sharedlibraries/testutil" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" ) @@ -45,9 +46,9 @@ func testArch(t *testing.T, arch string) { require.NoError(t, err) if arch == runtime.GOARCH { - utils.WaitForProgramsToBeTraced(t, "shared_libraries", cmd.Process.Pid, utils.ManualTracingFallbackDisabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, "shared_libraries", cmd.Process.Pid, utils.ManualTracingFallbackDisabled) } else { - utils.WaitForPathToBeBlocked(t, "shared_libraries", lib) + utils.WaitForPathToBeBlocked(t, consts.USMModuleName, "shared_libraries", lib) } } diff --git a/pkg/network/usm/istio.go b/pkg/network/usm/istio.go index 12bcc0df940466..3da1a13a0273e8 100644 --- a/pkg/network/usm/istio.go +++ b/pkg/network/usm/istio.go @@ -14,6 +14,7 @@ import ( "time" "github.com/DataDog/datadog-agent/pkg/network/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/process/monitor" "github.com/DataDog/datadog-agent/pkg/util/kernel" @@ -103,7 +104,7 @@ func newIstioMonitor(c *config.Config, mgr *manager.Manager) *istioMonitor { procRoot := kernel.ProcFSRoot() return &istioMonitor{ - registry: utils.NewFileRegistry("istio"), + registry: utils.NewFileRegistry(consts.USMModuleName, "istio"), procRoot: procRoot, envoyCmd: c.EnvoyPath, done: make(chan struct{}), @@ -187,7 +188,7 @@ func (m *istioMonitor) Start() { } }() - utils.AddAttacher("istio", m) + utils.AddAttacher(consts.USMModuleName, "istio", m) log.Info("Istio monitoring enabled") } diff --git a/pkg/network/usm/kafka_monitor_test.go b/pkg/network/usm/kafka_monitor_test.go index bd56759eb271ff..c9fd9f5ca37766 100644 --- a/pkg/network/usm/kafka_monitor_test.go +++ b/pkg/network/usm/kafka_monitor_test.go @@ -44,6 +44,7 @@ import ( gotlsutils "github.com/DataDog/datadog-agent/pkg/network/protocols/tls/gotls/testutil" "github.com/DataDog/datadog-agent/pkg/network/tracer/testutil/proxy" usmconfig "github.com/DataDog/datadog-agent/pkg/network/usm/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/util/kernel" ) @@ -560,7 +561,7 @@ func (s *KafkaProtocolParsingSuite) testKafkaProtocolParsing(t *testing.T, tls b }) monitor := newKafkaMonitor(t, cfg) if tls && cfg.EnableGoTLSSupport { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } tt.testBody(t, &tt.context, monitor) }) @@ -1158,7 +1159,7 @@ func testKafkaFetchRaw(t *testing.T, tls bool, apiVersion int) { monitor := newKafkaMonitor(t, getDefaultTestConfiguration(tls)) if tls { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyPid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyPid, utils.ManualTracingFallbackEnabled) } for _, tt := range tests { @@ -1386,7 +1387,7 @@ func testKafkaProduceRaw(t *testing.T, tls bool, apiVersion int) { monitor := newKafkaMonitor(t, getDefaultTestConfiguration(tls)) if tls { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyPid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyPid, utils.ManualTracingFallbackEnabled) } for _, tt := range tests { diff --git a/pkg/network/usm/monitor.go b/pkg/network/usm/monitor.go index f1f73ab50d8583..4ee3d2e535d68b 100644 --- a/pkg/network/usm/monitor.go +++ b/pkg/network/usm/monitor.go @@ -25,6 +25,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/network/protocols" "github.com/DataDog/datadog-agent/pkg/network/protocols/telemetry" usmconfig "github.com/DataDog/datadog-agent/pkg/network/usm/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" usmstate "github.com/DataDog/datadog-agent/pkg/network/usm/state" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/process/monitor" @@ -168,9 +169,9 @@ func (m *Monitor) GetUSMStats() map[string]interface{} { response["error"] = startupError.Error() } - response["blocked_processes"] = utils.GetBlockedPathIDsList() + response["blocked_processes"] = utils.GetBlockedPathIDsList(consts.USMModuleName) - tracedPrograms := utils.GetTracedProgramList() + tracedPrograms := utils.GetTracedProgramList(consts.USMModuleName) response["traced_programs"] = tracedPrograms if m != nil { diff --git a/pkg/network/usm/monitor_tls_test.go b/pkg/network/usm/monitor_tls_test.go index 90966c91c2cdc7..d81a484aef3506 100644 --- a/pkg/network/usm/monitor_tls_test.go +++ b/pkg/network/usm/monitor_tls_test.go @@ -42,6 +42,7 @@ import ( gotlstestutil "github.com/DataDog/datadog-agent/pkg/network/protocols/tls/gotls/testutil" "github.com/DataDog/datadog-agent/pkg/network/protocols/tls/nodejs" usmconfig "github.com/DataDog/datadog-agent/pkg/network/usm/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" usmtestutil "github.com/DataDog/datadog-agent/pkg/network/usm/testutil" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" procmontestutil "github.com/DataDog/datadog-agent/pkg/process/monitor/testutil" @@ -184,7 +185,7 @@ func (s *tlsSuite) TestHTTPSViaLibraryIntegration() { func testHTTPSLibrary(t *testing.T, cfg *config.Config, fetchCmd, prefetchLibs []string) { usmMonitor := setupUSMTLSMonitor(t, cfg) // not ideal but, short process are hard to catch - utils.WaitForProgramsToBeTraced(t, "shared_libraries", prefetchLib(t, prefetchLibs...).Process.Pid, utils.ManualTracingFallbackDisabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, "shared_libraries", prefetchLib(t, prefetchLibs...).Process.Pid, utils.ManualTracingFallbackDisabled) // Issue request using fetchCmd (wget, curl, ...) // This is necessary (as opposed to using net/http) because we want to @@ -199,7 +200,7 @@ func testHTTPSLibrary(t *testing.T, cfg *config.Config, fetchCmd, prefetchLibs [ requestCmd.Stderr = requestCmd.Stdout require.NoError(t, requestCmd.Start()) - utils.WaitForProgramsToBeTraced(t, "shared_libraries", requestCmd.Process.Pid, utils.ManualTracingFallbackDisabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, "shared_libraries", requestCmd.Process.Pid, utils.ManualTracingFallbackDisabled) if err := requestCmd.Wait(); err != nil { output, err := io.ReadAll(stdout) @@ -286,7 +287,7 @@ func (s *tlsSuite) TestOpenSSLVersions() { EnableTLS: true, }) - utils.WaitForProgramsToBeTraced(t, "shared_libraries", cmd.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, "shared_libraries", cmd.Process.Pid, utils.ManualTracingFallbackEnabled) client, requestFn := simpleGetRequestsGenerator(t, addressOfHTTPPythonServer) var requests []*nethttp.Request @@ -353,7 +354,7 @@ func (s *tlsSuite) TestOpenSSLVersionsSlowStart() { usmMonitor := setupUSMTLSMonitor(t, cfg) // Giving the tracer time to install the hooks - utils.WaitForProgramsToBeTraced(t, "shared_libraries", cmd.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, "shared_libraries", cmd.Process.Pid, utils.ManualTracingFallbackEnabled) // Send a warmup batch of requests to trigger the fallback behavior for i := 0; i < numberOfRequests; i++ { @@ -561,7 +562,7 @@ func TestOldConnectionRegression(t *testing.T) { usmMonitor := setupUSMTLSMonitor(t, cfg) // Ensure this test program is being traced - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, os.Getpid(), utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, os.Getpid(), utils.ManualTracingFallbackEnabled) // The HTTPServer used here effectively works as an "echo" servers and // returns back in the response whatever it received in the request @@ -632,7 +633,7 @@ func TestLimitListenerRegression(t *testing.T) { usmMonitor := setupUSMTLSMonitor(t, cfg) // Ensure this test program is being traced - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, os.Getpid(), utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, os.Getpid(), utils.ManualTracingFallbackEnabled) // Issue multiple HTTP requests for i := 0; i < 10; i++ { @@ -692,7 +693,7 @@ func testHTTPGoTLSCaptureNewProcess(t *testing.T, cfg *config.Config, isHTTP2 bo // spin-up goTLS client and issue requests after initialization command, runRequests := gotlstestutil.NewGoTLSClient(t, serverAddr, expectedOccurrences, isHTTP2) - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, command.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, command.Process.Pid, utils.ManualTracingFallbackEnabled) runRequests() checkRequests(t, usmMonitor, expectedOccurrences, reqs, isHTTP2) } @@ -729,7 +730,7 @@ func testHTTPGoTLSCaptureAlreadyRunning(t *testing.T, cfg *config.Config, isHTTP reqs[req] = false } - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, command.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, command.Process.Pid, utils.ManualTracingFallbackEnabled) issueRequestsFn() checkRequests(t, usmMonitor, expectedOccurrences, reqs, isHTTP2) } @@ -899,7 +900,7 @@ func (s *tlsSuite) TestNodeJSTLS() { cfg.EnableNodeJSMonitoring = true usmMonitor := setupUSMTLSMonitor(t, cfg) - utils.WaitForProgramsToBeTraced(t, "nodejs", int(nodeJSPID), utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, "nodejs", int(nodeJSPID), utils.ManualTracingFallbackEnabled) // This maps will keep track of whether the tracer saw this request already or not client, requestFn := simpleGetRequestsGenerator(t, fmt.Sprintf("localhost:%s", serverPort)) diff --git a/pkg/network/usm/nodejs.go b/pkg/network/usm/nodejs.go index 053bd34ef66d01..533460020a759e 100644 --- a/pkg/network/usm/nodejs.go +++ b/pkg/network/usm/nodejs.go @@ -15,6 +15,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/ebpf/uprobes" "github.com/DataDog/datadog-agent/pkg/network/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/process/monitor" "github.com/DataDog/datadog-agent/pkg/util/kernel" "github.com/DataDog/datadog-agent/pkg/util/log" @@ -130,7 +131,7 @@ func newNodeJSMonitor(c *config.Config, mgr *manager.Manager) (*nodeJSMonitor, e } procMon := monitor.GetProcessMonitor() - attacher, err := uprobes.NewUprobeAttacher(nodeJsAttacherName, attachCfg, mgr, uprobes.NopOnAttachCallback, &uprobes.NativeBinaryInspector{}, procMon) + attacher, err := uprobes.NewUprobeAttacher(consts.USMModuleName, nodeJsAttacherName, attachCfg, mgr, uprobes.NopOnAttachCallback, &uprobes.NativeBinaryInspector{}, procMon) if err != nil { return nil, fmt.Errorf("cannot create uprobe attacher: %w", err) } diff --git a/pkg/network/usm/postgres_monitor_test.go b/pkg/network/usm/postgres_monitor_test.go index 279aa7ad1319e5..9243756cfe76c1 100644 --- a/pkg/network/usm/postgres_monitor_test.go +++ b/pkg/network/usm/postgres_monitor_test.go @@ -31,6 +31,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/network/protocols/postgres/ebpf" protocolsUtils "github.com/DataDog/datadog-agent/pkg/network/protocols/testutil" gotlstestutil "github.com/DataDog/datadog-agent/pkg/network/protocols/tls/gotls/testutil" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" ) @@ -191,7 +192,7 @@ func testDecoding(t *testing.T, isTLS bool) { monitor := setupUSMTLSMonitor(t, getPostgresDefaultTestConfiguration(isTLS)) if isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, os.Getpid(), utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, os.Getpid(), utils.ManualTracingFallbackEnabled) } tests := []postgresParsingTestAttributes{ diff --git a/pkg/network/usm/sharedlibraries/watcher.go b/pkg/network/usm/sharedlibraries/watcher.go index ab0a9a4bfff817..b8d2fc6c72d43f 100644 --- a/pkg/network/usm/sharedlibraries/watcher.go +++ b/pkg/network/usm/sharedlibraries/watcher.go @@ -20,6 +20,7 @@ import ( ddebpf "github.com/DataDog/datadog-agent/pkg/ebpf" "github.com/DataDog/datadog-agent/pkg/network/config" "github.com/DataDog/datadog-agent/pkg/network/protocols/telemetry" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/process/monitor" "github.com/DataDog/datadog-agent/pkg/util/kernel" @@ -84,7 +85,7 @@ func NewWatcher(cfg *config.Config, rules ...Rule) (*Watcher, error) { loadEvents: ebpfProgram.GetPerfHandler(), processMonitor: monitor.GetProcessMonitor(), ebpfProgram: ebpfProgram, - registry: utils.NewFileRegistry("shared_libraries"), + registry: utils.NewFileRegistry(consts.USMModuleName, "shared_libraries"), libHits: telemetry.NewCounter("usm.so_watcher.hits", telemetry.OptPrometheus), libMatches: telemetry.NewCounter("usm.so_watcher.matches", telemetry.OptPrometheus), @@ -286,5 +287,5 @@ func (w *Watcher) Start() { log.Errorf("error starting shared library detection eBPF program: %s", err) } - utils.AddAttacher("native", w) + utils.AddAttacher(consts.USMModuleName, "native", w) } diff --git a/pkg/network/usm/tests/tracer_usm_linux_test.go b/pkg/network/usm/tests/tracer_usm_linux_test.go index 63e84241e2a935..a3186d6a8d8838 100644 --- a/pkg/network/usm/tests/tracer_usm_linux_test.go +++ b/pkg/network/usm/tests/tracer_usm_linux_test.go @@ -58,6 +58,7 @@ import ( tracertestutil "github.com/DataDog/datadog-agent/pkg/network/tracer/testutil" "github.com/DataDog/datadog-agent/pkg/network/usm" usmconfig "github.com/DataDog/datadog-agent/pkg/network/usm/config" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/testutil/grpc" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/process/util" @@ -2409,11 +2410,11 @@ func testProtocolClassificationLinux(t *testing.T, tr *tracer.Tracer, clientHost // Wraps the call to the Go-TLS attach function and waits for the program to be traced. func goTLSAttachPID(t *testing.T, pid int) { t.Helper() - if utils.IsProgramTraced(usm.GoTLSAttacherName, pid) { + if utils.IsProgramTraced(consts.USMModuleName, usm.GoTLSAttacherName, pid) { return } require.NoError(t, usm.GoTLSAttachPID(uint32(pid))) - utils.WaitForProgramsToBeTraced(t, usm.GoTLSAttacherName, pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, usm.GoTLSAttacherName, pid, utils.ManualTracingFallbackEnabled) } // goTLSDetachPID detaches the Go-TLS monitoring from the given PID. @@ -2422,13 +2423,13 @@ func goTLSDetachPID(t *testing.T, pid int) { t.Helper() // The program is not traced; nothing to do. - if !utils.IsProgramTraced(usm.GoTLSAttacherName, pid) { + if !utils.IsProgramTraced(consts.USMModuleName, usm.GoTLSAttacherName, pid) { return } require.NoError(t, usm.GoTLSDetachPID(uint32(pid))) require.Eventually(t, func() bool { - return !utils.IsProgramTraced(usm.GoTLSAttacherName, pid) + return !utils.IsProgramTraced(consts.USMModuleName, usm.GoTLSAttacherName, pid) }, 5*time.Second, 100*time.Millisecond, "process %v is still traced by Go-TLS after detaching", pid) } diff --git a/pkg/network/usm/usm_grpc_monitor_test.go b/pkg/network/usm/usm_grpc_monitor_test.go index d153a50298a17c..2a931a2d5d7076 100644 --- a/pkg/network/usm/usm_grpc_monitor_test.go +++ b/pkg/network/usm/usm_grpc_monitor_test.go @@ -26,6 +26,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/network/protocols/http" "github.com/DataDog/datadog-agent/pkg/network/protocols/http2" gotlsutils "github.com/DataDog/datadog-agent/pkg/network/protocols/tls/gotls/testutil" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/testutil/grpc" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/util/kernel" @@ -121,7 +122,7 @@ func (s *usmGRPCSuite) TestSimpleGRPCScenarios() { usmMonitor := setupUSMTLSMonitor(t, s.getConfig()) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, srv.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, srv.Process.Pid, utils.ManualTracingFallbackEnabled) } // c is a stream endpoint // a + b are unary endpoints @@ -449,7 +450,7 @@ func (s *usmGRPCSuite) TestLargeBodiesGRPCScenarios() { usmMonitor := setupUSMTLSMonitor(t, s.getConfig()) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, srv.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, srv.Process.Pid, utils.ManualTracingFallbackEnabled) } // Random string generation is an heavy operation, and it's proportional for the length (15MB) diff --git a/pkg/network/usm/usm_http2_monitor_test.go b/pkg/network/usm/usm_http2_monitor_test.go index 8503e1e96cf0eb..564bd1adced945 100644 --- a/pkg/network/usm/usm_http2_monitor_test.go +++ b/pkg/network/usm/usm_http2_monitor_test.go @@ -44,6 +44,7 @@ import ( usmhttp2 "github.com/DataDog/datadog-agent/pkg/network/protocols/http2" gotlsutils "github.com/DataDog/datadog-agent/pkg/network/protocols/tls/gotls/testutil" "github.com/DataDog/datadog-agent/pkg/network/tracer/testutil/proxy" + "github.com/DataDog/datadog-agent/pkg/network/usm/consts" "github.com/DataDog/datadog-agent/pkg/network/usm/utils" "github.com/DataDog/datadog-agent/pkg/util/kernel" ) @@ -151,7 +152,7 @@ func (s *usmHTTP2Suite) TestHTTP2DynamicTableCleanup() { monitor := setupUSMTLSMonitor(t, cfg) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } clients := getHTTP2UnixClientArray(2, unixPath) @@ -213,7 +214,7 @@ func (s *usmHTTP2Suite) TestSimpleHTTP2() { monitor := setupUSMTLSMonitor(t, cfg) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } tests := []struct { @@ -401,7 +402,7 @@ func (s *usmHTTP2Suite) TestHTTP2KernelTelemetry() { t.Run(tt.name, func(t *testing.T) { monitor := setupUSMTLSMonitor(t, cfg) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } tt.runClients(t, 1) @@ -456,7 +457,7 @@ func (s *usmHTTP2Suite) TestHTTP2ManyDifferentPaths() { monitor := setupUSMTLSMonitor(t, cfg) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } const ( @@ -522,7 +523,7 @@ func (s *usmHTTP2Suite) TestRawTraffic() { require.NoError(t, proxy.WaitForConnectionReady(unixPath)) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } tests := []struct { name string @@ -1320,7 +1321,7 @@ func (s *usmHTTP2Suite) TestDynamicTable() { usmMonitor := setupUSMTLSMonitor(t, cfg) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } c := dialHTTP2Server(t) @@ -1406,7 +1407,7 @@ func (s *usmHTTP2Suite) TestRemainderTable() { t.Run(tt.name, func(t *testing.T) { usmMonitor := setupUSMTLSMonitor(t, cfg) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } c := dialHTTP2Server(t) @@ -1476,7 +1477,7 @@ func (s *usmHTTP2Suite) TestRawHuffmanEncoding() { t.Run(tt.name, func(t *testing.T) { usmMonitor := setupUSMTLSMonitor(t, cfg) if s.isTLS { - utils.WaitForProgramsToBeTraced(t, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) + utils.WaitForProgramsToBeTraced(t, consts.USMModuleName, GoTLSAttacherName, proxyProcess.Process.Pid, utils.ManualTracingFallbackEnabled) } c := dialHTTP2Server(t) diff --git a/pkg/network/usm/utils/debugger.go b/pkg/network/usm/utils/debugger.go index ce24d8d1ba3ac7..4da685bf2fbc90 100644 --- a/pkg/network/usm/utils/debugger.go +++ b/pkg/network/usm/utils/debugger.go @@ -46,41 +46,57 @@ type PathIdentifierWithSamplePath struct { SamplePath string } -// TracedProgramsEndpoint generates a summary of all active uprobe-based -// programs along with their file paths and PIDs. +// GetTracedProgramsEndpoint returns a callback for the given module name, that +// generates a summary of all active uprobe-based programs along with their file paths and PIDs. // This is used for debugging purposes only. -func TracedProgramsEndpoint(w http.ResponseWriter, _ *http.Request) { - otherutils.WriteAsJSON(w, debugger.GetTracedPrograms()) +func GetTracedProgramsEndpoint(moduleName string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { + otherutils.WriteAsJSON(w, debugger.GetTracedPrograms(moduleName)) + } } -// BlockedPathIDEndpoint generates a summary of all blocked uprobe-based -// programs that are blocked in the registry along with their device and inode numbers, and sample path. +// GetBlockedPathIDEndpoint returns a callback for the given module name, that +// generates a summary of all blocked uprobe-based programs that are blocked in the +// registry along with their device and inode numbers, and sample path. // This is used for debugging purposes only. -func BlockedPathIDEndpoint(w http.ResponseWriter, _ *http.Request) { - otherutils.WriteAsJSON(w, debugger.GetAllBlockedPathIDs()) +func GetBlockedPathIDEndpoint(moduleName string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { + otherutils.WriteAsJSON(w, debugger.GetAllBlockedPathIDs(moduleName)) + } } -// ClearBlockedEndpoint clears the lists of blocked paths. -func ClearBlockedEndpoint(_ http.ResponseWriter, _ *http.Request) { - debugger.ClearBlocked() +// GetClearBlockedEndpoint returns a callback for the given module name, that clears the lists of blocked paths. +func GetClearBlockedEndpoint(moduleName string) func(http.ResponseWriter, *http.Request) { + return func(http.ResponseWriter, *http.Request) { + debugger.ClearBlocked(moduleName) + } } var debugger *tlsDebugger +type attacherMap = map[string]Attacher + type tlsDebugger struct { mux sync.Mutex - registries []*FileRegistry - attachers map[string]Attacher + registries map[string][]*FileRegistry + // attachers is a mapping from a module name to a map of attacher names to Attacher instances. + attachers map[string]attacherMap } -func (d *tlsDebugger) AddRegistry(r *FileRegistry) { +// AddRegistry adds a new `FileRegistry` instance to the debugger, and associates it with the given module name. +func (d *tlsDebugger) AddRegistry(moduleName string, r *FileRegistry) { d.mux.Lock() defer d.mux.Unlock() - d.registries = append(d.registries, r) + if _, ok := d.registries[moduleName]; !ok { + d.registries[moduleName] = []*FileRegistry{r} + } else { + d.registries[moduleName] = append(d.registries[moduleName], r) + } } -func (d *tlsDebugger) GetTracedPrograms() []TracedProgram { +// GetTracedPrograms returns a list of TracedPrograms for each `FileRegistry` instance belong to the given module. +func (d *tlsDebugger) GetTracedPrograms(moduleName string) []TracedProgram { d.mux.Lock() defer d.mux.Unlock() @@ -88,7 +104,7 @@ func (d *tlsDebugger) GetTracedPrograms() []TracedProgram { // Iterate over each `FileRegistry` instance: // Examples of this would be: "shared_libraries", "istio", "goTLS" etc - for _, registry := range d.registries { + for _, registry := range d.registries[moduleName] { programType := registry.telemetry.programName tracedProgramsByID := make(map[PathIdentifier]*TracedProgram) @@ -129,13 +145,13 @@ func (d *tlsDebugger) GetTracedPrograms() []TracedProgram { } // GetAllBlockedPathIDs returns a list of BlockedProcess blocked process for each `FileRegistry` instance. -func (d *tlsDebugger) GetAllBlockedPathIDs() []BlockedProcess { +func (d *tlsDebugger) GetAllBlockedPathIDs(moduleName string) []BlockedProcess { all := make([]BlockedProcess, 0, len(d.registries)) // Iterate over each `FileRegistry` instance: // Examples of this would be: "shared_libraries", "istio", "goTLS" etc - for _, registry := range d.registries { - blockedPathIdentifiers := d.GetBlockedPathIDsWithSamplePath(registry.telemetry.programName) + for _, registry := range d.registries[moduleName] { + blockedPathIdentifiers := d.GetBlockedPathIDsWithSamplePath(moduleName, registry.telemetry.programName) if len(blockedPathIdentifiers) > 0 { all = append(all, BlockedProcess{ ProgramType: registry.telemetry.programName, @@ -149,11 +165,11 @@ func (d *tlsDebugger) GetAllBlockedPathIDs() []BlockedProcess { // GetBlockedPathIDs returns a list of PathIdentifiers blocked in the // registry for the specified program type. -func (d *tlsDebugger) GetBlockedPathIDs(programType string) []PathIdentifier { +func (d *tlsDebugger) GetBlockedPathIDs(moduleName, programType string) []PathIdentifier { d.mux.Lock() defer d.mux.Unlock() - for _, registry := range d.registries { + for _, registry := range d.registries[moduleName] { if registry.telemetry.programName != programType { continue } @@ -168,11 +184,11 @@ func (d *tlsDebugger) GetBlockedPathIDs(programType string) []PathIdentifier { } // ClearBlocked clears the list of blocked paths for all registries. -func (d *tlsDebugger) ClearBlocked() { +func (d *tlsDebugger) ClearBlocked(moduleName string) { d.mux.Lock() defer d.mux.Unlock() - for _, registry := range d.registries { + for _, registry := range d.registries[moduleName] { registry.m.Lock() registry.blocklistByID.Purge() registry.m.Unlock() @@ -181,11 +197,11 @@ func (d *tlsDebugger) ClearBlocked() { // GetBlockedPathIDsWithSamplePath returns a list of PathIdentifiers with a matching sample path blocked in the // registry for the specified program type. -func (d *tlsDebugger) GetBlockedPathIDsWithSamplePath(programType string) []PathIdentifierWithSamplePath { +func (d *tlsDebugger) GetBlockedPathIDsWithSamplePath(moduleName, programType string) []PathIdentifierWithSamplePath { d.mux.Lock() defer d.mux.Unlock() - for _, registry := range d.registries { + for _, registry := range d.registries[moduleName] { if registry.telemetry.programName != programType { continue } @@ -210,17 +226,20 @@ func (d *tlsDebugger) GetBlockedPathIDsWithSamplePath(programType string) []Path } // AddAttacher adds an attacher to the debugger. -func (d *tlsDebugger) AddAttacher(name string, a Attacher) { +func (d *tlsDebugger) AddAttacher(moduleName, name string, a Attacher) { d.mux.Lock() defer d.mux.Unlock() - d.attachers[name] = a + if _, ok := d.attachers[moduleName]; !ok { + d.attachers[moduleName] = make(map[string]Attacher) + } + d.attachers[moduleName][name] = a } // AddAttacher adds an attacher to the debugger. // Used to wrap the internal debugger instance. -func AddAttacher(name string, a Attacher) { - debugger.AddAttacher(name, a) +func AddAttacher(moduleName, name string, a Attacher) { + debugger.AddAttacher(moduleName, name, a) } // attachRequestBody represents the request body for the attach/detach PID endpoint. @@ -250,7 +269,7 @@ func (m callbackType) String() string { } // runAttacherCallback runs the attacher callback for the given request. -func (d *tlsDebugger) runAttacherCallback(w http.ResponseWriter, r *http.Request, mode callbackType) { +func (d *tlsDebugger) runAttacherCallback(moduleName string, w http.ResponseWriter, r *http.Request, mode callbackType) { if r.Method != http.MethodPost { w.WriteHeader(http.StatusMethodNotAllowed) fmt.Fprintf(w, "Only POST requests are allowed") @@ -266,7 +285,14 @@ func (d *tlsDebugger) runAttacherCallback(w http.ResponseWriter, r *http.Request } d.mux.Lock() - attacher, ok := d.attachers[reqBody.Type] + moduleAttachers, ok := d.attachers[moduleName] + if !ok { + d.mux.Unlock() + w.WriteHeader(http.StatusBadRequest) + fmt.Fprintf(w, "module %q is unrecognized", moduleName) + return + } + attacher, ok := moduleAttachers[reqBody.Type] d.mux.Unlock() if !ok { w.WriteHeader(http.StatusBadRequest) @@ -286,35 +312,40 @@ func (d *tlsDebugger) runAttacherCallback(w http.ResponseWriter, r *http.Request fmt.Fprintf(w, "%s successfully %sed PID %d", reqBody.Type, mode.String(), reqBody.PID) } -// AttachPIDEndpoint attaches a PID to an eBPF program. -func AttachPIDEndpoint(w http.ResponseWriter, r *http.Request) { - debugger.runAttacherCallback(w, r, attach) +// GetAttachPIDEndpoint returns a callback for the given module name, that attaches a PID to an eBPF program. +func GetAttachPIDEndpoint(moduleName string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + debugger.runAttacherCallback(moduleName, w, r, attach) + } } -// DetachPIDEndpoint detaches a PID from an eBPF program. -func DetachPIDEndpoint(w http.ResponseWriter, r *http.Request) { - debugger.runAttacherCallback(w, r, detach) +// GetDetachPIDEndpoint returns a callback for the given module name, that detaches a PID from an eBPF program. +func GetDetachPIDEndpoint(moduleName string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + debugger.runAttacherCallback(moduleName, w, r, detach) + } } func init() { debugger = &tlsDebugger{ - attachers: make(map[string]Attacher), + registries: make(map[string][]*FileRegistry), + attachers: make(map[string]map[string]Attacher), } } // GetBlockedPathIDsList returns a list of PathIdentifiers blocked in the // registry for the all programs type. -func GetBlockedPathIDsList() []BlockedProcess { +func GetBlockedPathIDsList(moduleName string) []BlockedProcess { if debugger == nil { return nil } - return debugger.GetAllBlockedPathIDs() + return debugger.GetAllBlockedPathIDs(moduleName) } // GetTracedProgramList returns a list of traced programs. -func GetTracedProgramList() []TracedProgram { +func GetTracedProgramList(moduleName string) []TracedProgram { if debugger == nil { return nil } - return debugger.GetTracedPrograms() + return debugger.GetTracedPrograms(moduleName) } diff --git a/pkg/network/usm/utils/debugger_test.go b/pkg/network/usm/utils/debugger_test.go new file mode 100644 index 00000000000000..b5f29c65a0c59d --- /dev/null +++ b/pkg/network/usm/utils/debugger_test.go @@ -0,0 +1,170 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +//go:build linux + +package utils + +import ( + "bytes" + "encoding/json" + "errors" + "io" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +type mockAttacher struct { + overrideAttachPID func(uint32) error + overrideDetachPID func(uint32) error +} + +func (m *mockAttacher) AttachPID(pid uint32) error { + if m.overrideAttachPID != nil { + return m.overrideAttachPID(pid) + } + return nil +} + +func (m *mockAttacher) DetachPID(pid uint32) error { + if m.overrideDetachPID != nil { + return m.overrideDetachPID(pid) + } + return nil +} + +func TestRunAttacherCallback(t *testing.T) { + tests := []struct { + name string + method string + moduleName string + body interface{} + mode callbackType + expectedStatus int + expectedBody string + attacherSetup func(Attacher) + }{ + { + name: "Non-POST method", + method: http.MethodGet, + moduleName: "testModule", + body: attachRequestBody{Type: "testType", PID: 123}, + mode: attach, + expectedStatus: http.StatusMethodNotAllowed, + expectedBody: "Only POST requests are allowed", + }, + { + name: "Malformed JSON body", + method: http.MethodPost, + moduleName: "testModule", + body: "{malformed_json}", + mode: attach, + expectedStatus: http.StatusBadRequest, + expectedBody: "Error decoding request body", + }, + { + name: "Unrecognized module", + method: http.MethodPost, + moduleName: "unknownModule", + body: attachRequestBody{Type: "testType", PID: 123}, + mode: attach, + expectedStatus: http.StatusBadRequest, + expectedBody: `module "unknownModule" is unrecognized`, + }, + { + name: "Unrecognized attacher type", + method: http.MethodPost, + moduleName: "testModule", + body: attachRequestBody{Type: "unknownType", PID: 123}, + mode: attach, + expectedStatus: http.StatusBadRequest, + expectedBody: `Module "unknownType" is not enabled`, + }, + { + name: "Attach callback error", + method: http.MethodPost, + moduleName: "testModule", + body: attachRequestBody{Type: "testType", PID: 123}, + mode: attach, + expectedStatus: http.StatusInternalServerError, + expectedBody: "Error attaching PID", + attacherSetup: func(att Attacher) { + att.(*mockAttacher).overrideAttachPID = func(uint32) error { return errors.New("attach error") } + }, + }, + { + name: "Detach callback error", + method: http.MethodPost, + moduleName: "testModule", + body: attachRequestBody{Type: "testType", PID: 123}, + mode: detach, + expectedStatus: http.StatusInternalServerError, + expectedBody: "Error detaching PID", + attacherSetup: func(att Attacher) { + att.(*mockAttacher).overrideDetachPID = func(uint32) error { return errors.New("detach error") } + }, + }, + { + name: "Successful attach", + method: http.MethodPost, + moduleName: "testModule", + body: attachRequestBody{Type: "testType", PID: 123}, + mode: attach, + expectedStatus: http.StatusOK, + expectedBody: "testType successfully attached PID 123", + }, + { + name: "Successful detach", + method: http.MethodPost, + moduleName: "testModule", + body: attachRequestBody{Type: "testType", PID: 123}, + mode: detach, + expectedStatus: http.StatusOK, + expectedBody: "testType successfully detached PID 123", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + d := &tlsDebugger{ + attachers: map[string]attacherMap{ + "testModule": { + "testType": &mockAttacher{}, + }, + }, + } + + if tt.attacherSetup != nil { + tt.attacherSetup(d.attachers["testModule"]["testType"]) + } + + var reqBody bytes.Buffer + if bodyStr, ok := tt.body.(string); ok { + reqBody = *bytes.NewBufferString(bodyStr) + } else if body, ok := tt.body.(attachRequestBody); ok { + json.NewEncoder(&reqBody).Encode(body) + } + + req := httptest.NewRequest(tt.method, "/attach", &reqBody) + w := httptest.NewRecorder() + + d.runAttacherCallback(tt.moduleName, w, req, tt.mode) + + res := w.Result() + defer res.Body.Close() + + if res.StatusCode != tt.expectedStatus { + t.Errorf("Expected status %d, got %d", tt.expectedStatus, res.StatusCode) + } + + body, _ := io.ReadAll(res.Body) + if !strings.Contains(string(body), tt.expectedBody) { + t.Errorf("Expected body to contain %q, got %q", tt.expectedBody, string(body)) + } + }) + } +} diff --git a/pkg/network/usm/utils/debugger_testutils.go b/pkg/network/usm/utils/debugger_testutils.go index b997133ae6a1fa..29b73fce037206 100644 --- a/pkg/network/usm/utils/debugger_testutils.go +++ b/pkg/network/usm/utils/debugger_testutils.go @@ -26,8 +26,8 @@ const ( ) // GetTracedPrograms returns a list of traced programs by the specific program type -func GetTracedPrograms(programType string) []TracedProgram { - res := debugger.GetTracedPrograms() +func GetTracedPrograms(moduleName, programType string) []TracedProgram { + res := debugger.GetTracedPrograms(moduleName) i := 0 // output index for _, x := range res { if x.ProgramType == programType { @@ -43,14 +43,15 @@ func GetTracedPrograms(programType string) []TracedProgram { // in the same test will cause the debugger to contain multiple and old instances of the same program. func ResetDebugger() { debugger = &tlsDebugger{ - attachers: make(map[string]Attacher), + registries: make(map[string][]*FileRegistry), + attachers: make(map[string]map[string]Attacher), } } // IsProgramTraced checks if the process with the provided PID is // traced. -func IsProgramTraced(programType string, pid int) bool { - traced := GetTracedPrograms(programType) +func IsProgramTraced(moduleName, programType string, pid int) bool { + traced := GetTracedPrograms(moduleName, programType) for _, prog := range traced { if slices.Contains[[]uint32](prog.PIDs, uint32(pid)) { return true @@ -59,12 +60,12 @@ func IsProgramTraced(programType string, pid int) bool { return false } -// WaitForProgramsToBeTraced waits for the program to be traced by the debugger -func WaitForProgramsToBeTraced(t *testing.T, programType string, pid int, traceManually TraceMethod) { +// WaitForProgramsToBeTraced waits for the program to be traced by the given programs type of the given module. +func WaitForProgramsToBeTraced(t *testing.T, moduleName, programType string, pid int, traceManually TraceMethod) { // Wait for the program to be traced end := time.Now().Add(time.Second * 5) for time.Now().Before(end) { - if IsProgramTraced(programType, pid) { + if IsProgramTraced(moduleName, programType, pid) { return } time.Sleep(time.Millisecond * 100) @@ -78,24 +79,24 @@ func WaitForProgramsToBeTraced(t *testing.T, programType string, pid int, traceM t.Logf("process %v is not traced by %v, trying to attach manually", pid, programType) // Get attacher for the program type - attacher, ok := debugger.attachers[programType] + attacher, ok := debugger.attachers[moduleName][programType] require.True(t, ok, "attacher for %v not found", programType) // Try to attach the PID. Any error other than ErrPathIsAlreadyRegistered is a failure. if err := attacher.AttachPID(uint32(pid)); err != ErrPathIsAlreadyRegistered { require.NoError(t, err) } require.Eventuallyf(t, func() bool { - return IsProgramTraced(programType, pid) + return IsProgramTraced(moduleName, programType, pid) }, time.Second*5, time.Millisecond*100, "process %v is not traced by %v", pid, programType) } // WaitForPathToBeBlocked waits for the path to be blocked from tracing in the // registry (due to failing activation). -func WaitForPathToBeBlocked(t *testing.T, programType string, path string) { +func WaitForPathToBeBlocked(t *testing.T, moduleName, programType string, path string) { pathID, err := NewPathIdentifier(path) require.NoError(t, err) require.Eventuallyf(t, func() bool { - blocked := debugger.GetBlockedPathIDs(programType) + blocked := debugger.GetBlockedPathIDs(moduleName, programType) for _, id := range blocked { if id == pathID { return true diff --git a/pkg/network/usm/utils/debugger_windows.go b/pkg/network/usm/utils/debugger_windows.go index 93a4b0c8d85872..1b2d634139f67f 100644 --- a/pkg/network/usm/utils/debugger_windows.go +++ b/pkg/network/usm/utils/debugger_windows.go @@ -10,27 +10,37 @@ package utils import "net/http" -// TracedProgramsEndpoint is not supported on Windows -func TracedProgramsEndpoint(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(404) +// GetTracedProgramsEndpoint is not supported on Windows +func GetTracedProgramsEndpoint(string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(404) + } } -// BlockedPathIDEndpoint is not supported on Windows -func BlockedPathIDEndpoint(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(404) +// GetBlockedPathIDEndpoint is not supported on Windows +func GetBlockedPathIDEndpoint(string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(404) + } } -// ClearBlockedEndpoint is not supported on Windows -func ClearBlockedEndpoint(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(404) +// GetClearBlockedEndpoint is not supported on Windows +func GetClearBlockedEndpoint(string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(404) + } } -// AttachPIDEndpoint is not supported on Windows -func AttachPIDEndpoint(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(404) +// GetAttachPIDEndpoint is not supported on Windows +func GetAttachPIDEndpoint(string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(404) + } } -// DetachPIDEndpoint is not supported on Windows -func DetachPIDEndpoint(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(404) +// GetDetachPIDEndpoint is not supported on Windows +func GetDetachPIDEndpoint(string) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(404) + } } diff --git a/pkg/network/usm/utils/file_registry.go b/pkg/network/usm/utils/file_registry.go index 1d04cbcebab50d..177a4ac7c5857e 100644 --- a/pkg/network/usm/utils/file_registry.go +++ b/pkg/network/usm/utils/file_registry.go @@ -90,7 +90,7 @@ var IgnoreCB = func(FilePath) error { return nil } var ErrEnvironment = errors.New("Environment error, path will not be blocked") // NewFileRegistry creates a new `FileRegistry` instance -func NewFileRegistry(programName string) *FileRegistry { +func NewFileRegistry(moduleName, programName string) *FileRegistry { blocklistByID, err := simplelru.NewLRU[PathIdentifier, string](2000, nil) if err != nil { log.Warnf("running without block cache list, creation error: %s", err) @@ -106,7 +106,7 @@ func NewFileRegistry(programName string) *FileRegistry { // Add self to the debugger so we can inspect internal state of this // FileRegistry using our debugging endpoint - debugger.AddRegistry(r) + debugger.AddRegistry(moduleName, r) return r } diff --git a/pkg/network/usm/utils/file_registry_test.go b/pkg/network/usm/utils/file_registry_test.go index 376590a59958df..67b7c0984f313c 100644 --- a/pkg/network/usm/utils/file_registry_test.go +++ b/pkg/network/usm/utils/file_registry_test.go @@ -206,6 +206,10 @@ func TestRepeatedRegistrationsFromSamePID(t *testing.T) { assert.NotContains(t, r.GetRegisteredProcesses(), pid) } +const ( + testModuleName = "test" +) + func TestFailedRegistration(t *testing.T) { // Create a callback recorder that returns an error on purpose registerRecorder := new(CallbackRecorder) @@ -239,9 +243,9 @@ func TestFailedRegistration(t *testing.T) { // This is because we have block-listed this file assert.Equal(t, 1, registerRecorder.CallsForPathID(pathID)) - assert.Contains(t, debugger.GetBlockedPathIDs(""), pathID) - debugger.ClearBlocked() - assert.Empty(t, debugger.GetBlockedPathIDs("")) + assert.Contains(t, debugger.GetBlockedPathIDs(testModuleName, ""), pathID) + debugger.ClearBlocked(testModuleName) + assert.Empty(t, debugger.GetBlockedPathIDs(testModuleName, "")) } func TestShortLivedProcess(t *testing.T) { @@ -403,5 +407,5 @@ func newFileRegistry() *FileRegistry { // Ensure that tests relying on telemetry data will always have a clean slate telemetry.Clear() ResetDebugger() - return NewFileRegistry("") + return NewFileRegistry(testModuleName, "") } From 7d157f1dac33ea51748e94ee81bf84f610d12618 Mon Sep 17 00:00:00 2001 From: "agent-platform-auto-pr[bot]" <153269286+agent-platform-auto-pr[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:02:38 +0000 Subject: [PATCH 2/4] [test-infra-definitions][automated] Bump test-infra-definitions to 7cd5e8a62570a3d4ff27e07ce5a467abfd19cff1 (#31140) Co-authored-by: agent-platform-auto-pr[bot] <153269286+agent-platform-auto-pr[bot]@users.noreply.github.com> --- .gitlab/common/test_infra_version.yml | 2 +- test/new-e2e/go.mod | 2 +- test/new-e2e/go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab/common/test_infra_version.yml b/.gitlab/common/test_infra_version.yml index 3bf60ee98c97fe..b2461c4666a845 100644 --- a/.gitlab/common/test_infra_version.yml +++ b/.gitlab/common/test_infra_version.yml @@ -4,4 +4,4 @@ variables: # and check the job creating the image to make sure you have the right SHA prefix TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX: "" # Make sure to update test-infra-definitions version in go.mod as well - TEST_INFRA_DEFINITIONS_BUILDIMAGES: b436617374bf + TEST_INFRA_DEFINITIONS_BUILDIMAGES: 7cd5e8a62570 diff --git a/test/new-e2e/go.mod b/test/new-e2e/go.mod index 520e01a0310690..e98b190ac18c42 100644 --- a/test/new-e2e/go.mod +++ b/test/new-e2e/go.mod @@ -60,7 +60,7 @@ require ( // `TEST_INFRA_DEFINITIONS_BUILDIMAGES` matches the commit sha in the module version // Example: github.com/DataDog/test-infra-definitions v0.0.0-YYYYMMDDHHmmSS-0123456789AB // => TEST_INFRA_DEFINITIONS_BUILDIMAGES: 0123456789AB - github.com/DataDog/test-infra-definitions v0.0.0-20241114152759-b436617374bf + github.com/DataDog/test-infra-definitions v0.0.0-20241115164330-7cd5e8a62570 github.com/aws/aws-sdk-go-v2 v1.32.2 github.com/aws/aws-sdk-go-v2/config v1.27.40 github.com/aws/aws-sdk-go-v2/service/ec2 v1.164.2 diff --git a/test/new-e2e/go.sum b/test/new-e2e/go.sum index d613f612bb1533..cf334e8ff35f7b 100644 --- a/test/new-e2e/go.sum +++ b/test/new-e2e/go.sum @@ -16,8 +16,8 @@ github.com/DataDog/datadog-go/v5 v5.5.0 h1:G5KHeB8pWBNXT4Jtw0zAkhdxEAWSpWH00geHI github.com/DataDog/datadog-go/v5 v5.5.0/go.mod h1:K9kcYBlxkcPP8tvvjZZKs/m1edNAUFzBbdpTUKfCsuw= github.com/DataDog/mmh3 v0.0.0-20200805151601-30884ca2197a h1:m9REhmyaWD5YJ0P53ygRHxKKo+KM+nw+zz0hEdKztMo= github.com/DataDog/mmh3 v0.0.0-20200805151601-30884ca2197a/go.mod h1:SvsjzyJlSg0rKsqYgdcFxeEVflx3ZNAyFfkUHP0TxXg= -github.com/DataDog/test-infra-definitions v0.0.0-20241114152759-b436617374bf h1:wPI1Rnox8xn6I4BCZvKWarlwz8u/yZFt72Ylm82iJ/w= -github.com/DataDog/test-infra-definitions v0.0.0-20241114152759-b436617374bf/go.mod h1:l0n0FQYdWWQxbI5a2EkuynRQIteUQcYOaOhdxD9TvJs= +github.com/DataDog/test-infra-definitions v0.0.0-20241115164330-7cd5e8a62570 h1:vVkrzQIPIhgxZP+GMd+9UhILnZTj1Uf4wZlxhcDGysA= +github.com/DataDog/test-infra-definitions v0.0.0-20241115164330-7cd5e8a62570/go.mod h1:l0n0FQYdWWQxbI5a2EkuynRQIteUQcYOaOhdxD9TvJs= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/DataDog/zstd_0 v0.0.0-20210310093942-586c1286621f h1:5Vuo4niPKFkfwW55jV4vY0ih3VQ9RaQqeqY67fvRn8A= From d0a1d255c4ace26ffe6b1f62be6d6aa79edc904b Mon Sep 17 00:00:00 2001 From: Florent Clarret Date: Mon, 18 Nov 2024 10:28:04 +0100 Subject: [PATCH 3/4] Add dependencies to the `internal_kubernetes_deploy_experimental` job (#31078) --- .../internal_kubernetes_deploy.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.gitlab/internal_kubernetes_deploy/internal_kubernetes_deploy.yml b/.gitlab/internal_kubernetes_deploy/internal_kubernetes_deploy.yml index f98da3272164d1..017863198dad05 100644 --- a/.gitlab/internal_kubernetes_deploy/internal_kubernetes_deploy.yml +++ b/.gitlab/internal_kubernetes_deploy/internal_kubernetes_deploy.yml @@ -24,6 +24,22 @@ internal_kubernetes_deploy_experimental: artifacts: false - job: docker_trigger_cluster_agent_internal artifacts: false + - job: docker_build_agent7_windows1809 + artifacts: false + - job: docker_build_agent7_windows2022 + artifacts: false + - job: docker_build_agent7_windows1809_jmx + artifacts: false + - job: docker_build_agent7_windows2022_jmx + artifacts: false + - job: docker_build_agent7_windows1809_core + artifacts: false + - job: docker_build_agent7_windows2022_core + artifacts: false + - job: docker_build_agent7_windows1809_core_jmx + artifacts: false + - job: docker_build_agent7_windows2022_core_jmx + artifacts: false - job: k8s-e2e-main # Currently only require container Argo workflow artifacts: false optional: true From 947fdd4e30c4c349e74b0f8f2b37e8a0b0856087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Mon, 18 Nov 2024 12:10:48 +0100 Subject: [PATCH 4/4] github: fix create_rc workflow (#31160) --- .github/workflows/create_rc_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_rc_pr.yml b/.github/workflows/create_rc_pr.yml index ae15581d3cdea8..9bbc4194668919 100644 --- a/.github/workflows/create_rc_pr.yml +++ b/.github/workflows/create_rc_pr.yml @@ -64,7 +64,7 @@ jobs: with: ref: ${{ matrix.value }} fetch-depth: 0 - persist-credentials: false + persist-credentials: true - name: Install python uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0