From 27f4bf167b72bf8de981b7bf8ea6efca2e84e76f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:20:51 +0000 Subject: [PATCH 1/6] Update dependency DataDog/integrations-core to v7.61.0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1bd67c4..ee331c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -307,7 +307,7 @@ ARG INTEGRATIONS_CORE="\ system_core \ system_swap" -ARG DATADOG_INTEGRATIONS_CORE_VERSION=7.60.1 +ARG DATADOG_INTEGRATIONS_CORE_VERSION=7.61.0 RUN apk add --virtual .build-deps \ g++ \ gcc \ From 359f1ebf2fb7e84dfe005bfd32d07570c2a69bfc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:01:27 +0000 Subject: [PATCH 2/6] Update dependency DataDog/datadog-agent to v7.61.0 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1bd67c4..c0a2276 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,7 +86,7 @@ RUN apk add --no-cache \ py3-yaml \ python3-dev -ARG DATADOG_VERSION=7.60.1 +ARG DATADOG_VERSION=7.61.0 # datadog-agent has both branch and tag of the version. refs/tags/version must be checked-out. RUN git clone --depth=1 https://github.com/DataDog/datadog-agent.git /build/datadog-agent \ && cd /build/datadog-agent \ @@ -362,7 +362,7 @@ EXPOSE 8125/udp 8126/tcp HEALTHCHECK --interval=30s --timeout=5s --retries=2 \ CMD ["/probe.sh"] -ARG DATADOG_VERSION=7.60.1 +ARG DATADOG_VERSION=7.61.0 ENV DATADOG_INTEGRATIONS_CORE_VERSION=${DATADOG_INTEGRATIONS_CORE_VERSION} \ DATADOG_VERSION=${DATADOG_VERSION} From e847f9103f66d3917e2f639579887b661e7b0e20 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Tue, 14 Jan 2025 13:17:42 +0900 Subject: [PATCH 3/6] Apply patch to disable gpu monitor --- Dockerfile | 4 ++ disable-gpu-module.patch | 130 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 disable-gpu-module.patch diff --git a/Dockerfile b/Dockerfile index ba3e4fd..7aea7f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -146,7 +146,11 @@ RUN strip -s /build/datadog-agent/dev/lib/*.so COPY --from=systemd-builder /work/systemd/src/systemd/ /usr/include/systemd/ +COPY disable-gpu-module.patch / +RUN patch -p1 < /disable-gpu-module.patch + RUN invoke agent.build \ + --non-glibc \ --exclude-rtloader \ --build-exclude=jmx,kubeapiserver,gce,ec2,orchestrator diff --git a/disable-gpu-module.patch b/disable-gpu-module.patch new file mode 100644 index 0000000..c4ced1c --- /dev/null +++ b/disable-gpu-module.patch @@ -0,0 +1,130 @@ +diff --git a/cmd/system-probe/modules/all_linux.go b/cmd/system-probe/modules/all_linux.go +index 79b6f3d74a..75198e4b50 100644 +--- a/cmd/system-probe/modules/all_linux.go ++++ b/cmd/system-probe/modules/all_linux.go +@@ -3,7 +3,7 @@ + // This product includes software developed at Datadog (https://www.datadoghq.com/). + // Copyright 2016-present Datadog, Inc. + +-//go:build linux && !arm64 ++//go:build linux && !arm64 && !nonglibc + + // Package modules is all the module definitions for system-probe + package modules +diff --git a/cmd/system-probe/modules/all_linux_arm64.go b/cmd/system-probe/modules/all_linux_arm64.go +index e5a81541e5..663d2c804f 100644 +--- a/cmd/system-probe/modules/all_linux_arm64.go ++++ b/cmd/system-probe/modules/all_linux_arm64.go +@@ -3,7 +3,7 @@ + // This product includes software developed at Datadog (https://www.datadoghq.com/). + // Copyright 2024-present Datadog, Inc. + +-//go:build linux && arm64 ++//go:build linux && arm64 && !nonglibc + + // Package modules is all the module definitions for system-probe + package modules +diff --git a/cmd/system-probe/modules/gpu.go b/cmd/system-probe/modules/gpu.go +index 7ec273e7c2..d009389b1c 100644 +--- a/cmd/system-probe/modules/gpu.go ++++ b/cmd/system-probe/modules/gpu.go +@@ -3,7 +3,7 @@ + // This product includes software developed at Datadog (https://www.datadoghq.com/). + // Copyright 2024-present Datadog, Inc. + +-//go:build linux ++//go:build linux && !nonglibc + + package modules + +diff --git a/pkg/collector/corechecks/gpu/gpu.go b/pkg/collector/corechecks/gpu/gpu.go +index 1083db30ad..092a3b3b1f 100644 +--- a/pkg/collector/corechecks/gpu/gpu.go ++++ b/pkg/collector/corechecks/gpu/gpu.go +@@ -3,7 +3,7 @@ + // This product includes software developed at Datadog (https://www.datadoghq.com/). + // Copyright 2024-present Datadog, Inc. + +-//go:build linux ++//go:build linux && !nonglibc + + package gpu + +diff --git a/pkg/collector/corechecks/gpu/gpu_stub.go b/pkg/collector/corechecks/gpu/gpu_stub.go +index 5aefc60217..c507f2a843 100644 +--- a/pkg/collector/corechecks/gpu/gpu_stub.go ++++ b/pkg/collector/corechecks/gpu/gpu_stub.go +@@ -3,7 +3,7 @@ + // This product includes software developed at Datadog (https://www.datadoghq.com/). + // Copyright 2024-present Datadog, Inc. + +-//go:build !linux ++//go:build !linux || nonglibc + + package gpu + +diff --git a/tasks/agent.py b/tasks/agent.py +index b0220fcb60..bec7654b48 100644 +--- a/tasks/agent.py ++++ b/tasks/agent.py +@@ -140,6 +140,7 @@ def build( + bundle_ebpf=False, + agent_bin=None, + run_on=None, # noqa: U100, F841. Used by the run_on_devcontainer decorator ++ non_glibc=False, + ): + """ + Build the agent. If the bits to include in the build are not specified, +@@ -213,6 +214,9 @@ def build( + all_tags |= set(build_tags) + build_tags = list(all_tags) + ++ if non_glibc: ++ build_tags.append("nonglibc") ++ + cmd = "go build -mod={go_mod} {race_opt} {build_type} -tags \"{go_build_tags}\" " + + if not agent_bin: +diff --git a/tasks/system_probe.py b/tasks/system_probe.py +index 5ddffee149..6da208b6d2 100644 +--- a/tasks/system_probe.py ++++ b/tasks/system_probe.py +@@ -684,10 +684,12 @@ def build( + with_unit_test=False, + ebpf_compiler='clang', + static=False, ++ non_glibc=False, + ): + """ + Build the system-probe + """ ++ raise NameError('test') + if not is_macos: + build_object_files( + ctx, +@@ -710,6 +712,7 @@ def build( + strip_binary=strip_binary, + arch=arch, + static=static, ++ non_glibc=non_glibc, + ) + + +@@ -737,6 +740,7 @@ def build_sysprobe_binary( + strip_binary=False, + fips_mode=False, + static=False, ++ non_glibc=False, + ) -> None: + arch_obj = Arch.from_str(arch) + +@@ -759,6 +763,9 @@ def build_sysprobe_binary( + build_tags.extend(["osusergo", "netgo"]) + build_tags = list(set(build_tags).difference({"netcgo"})) + ++ if non_glibc: ++ build_tags.append("nonglibc") ++ + if not is_windows and "pcap" in build_tags: + build_libpcap(ctx) + cgo_flags = get_libpcap_cgo_flags(ctx, install_path) From a718842f39e784c957dbb8a42b473edfa4cd54a1 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 15 Jan 2025 15:42:33 +0900 Subject: [PATCH 4/6] Update patch --- disable-gpu-module.patch | 157 +++++++++++++++++++++++++++++++-------- 1 file changed, 125 insertions(+), 32 deletions(-) diff --git a/disable-gpu-module.patch b/disable-gpu-module.patch index c4ced1c..bc83c2c 100644 --- a/disable-gpu-module.patch +++ b/disable-gpu-module.patch @@ -1,5 +1,5 @@ diff --git a/cmd/system-probe/modules/all_linux.go b/cmd/system-probe/modules/all_linux.go -index 79b6f3d74a..75198e4b50 100644 +index 79b6f3d74a..0da0a6818a 100644 --- a/cmd/system-probe/modules/all_linux.go +++ b/cmd/system-probe/modules/all_linux.go @@ -3,7 +3,7 @@ @@ -7,12 +7,20 @@ index 79b6f3d74a..75198e4b50 100644 // Copyright 2016-present Datadog, Inc. -//go:build linux && !arm64 -+//go:build linux && !arm64 && !nonglibc ++//go:build linux && !arm64 && !glibc // Package modules is all the module definitions for system-probe package modules +@@ -30,7 +30,6 @@ var All = []module.Factory{ + Pinger, + Traceroute, + DiscoveryModule, +- GPUMonitoring, // GPU monitoring needs to be initialized afer EventMonitor, so that we have the event consumer ready + } + + func inactivityEventLog(_ time.Duration) { diff --git a/cmd/system-probe/modules/all_linux_arm64.go b/cmd/system-probe/modules/all_linux_arm64.go -index e5a81541e5..663d2c804f 100644 +index e5a81541e5..4c3bc6ba3c 100644 --- a/cmd/system-probe/modules/all_linux_arm64.go +++ b/cmd/system-probe/modules/all_linux_arm64.go @@ -3,7 +3,7 @@ @@ -20,12 +28,12 @@ index e5a81541e5..663d2c804f 100644 // Copyright 2024-present Datadog, Inc. -//go:build linux && arm64 -+//go:build linux && arm64 && !nonglibc ++//go:build linux && arm64 && !glibc // Package modules is all the module definitions for system-probe package modules diff --git a/cmd/system-probe/modules/gpu.go b/cmd/system-probe/modules/gpu.go -index 7ec273e7c2..d009389b1c 100644 +index c7dbac874d..4ef84fb1cf 100644 --- a/cmd/system-probe/modules/gpu.go +++ b/cmd/system-probe/modules/gpu.go @@ -3,7 +3,7 @@ @@ -38,7 +46,7 @@ index 7ec273e7c2..d009389b1c 100644 package modules diff --git a/pkg/collector/corechecks/gpu/gpu.go b/pkg/collector/corechecks/gpu/gpu.go -index 1083db30ad..092a3b3b1f 100644 +index dbaa9bbc3d..6fd31fcdd5 100644 --- a/pkg/collector/corechecks/gpu/gpu.go +++ b/pkg/collector/corechecks/gpu/gpu.go @@ -3,7 +3,7 @@ @@ -46,12 +54,12 @@ index 1083db30ad..092a3b3b1f 100644 // Copyright 2024-present Datadog, Inc. -//go:build linux -+//go:build linux && !nonglibc ++//go:build linux && glibc package gpu diff --git a/pkg/collector/corechecks/gpu/gpu_stub.go b/pkg/collector/corechecks/gpu/gpu_stub.go -index 5aefc60217..c507f2a843 100644 +index 9605813661..51706336f2 100644 --- a/pkg/collector/corechecks/gpu/gpu_stub.go +++ b/pkg/collector/corechecks/gpu/gpu_stub.go @@ -3,7 +3,7 @@ @@ -59,71 +67,156 @@ index 5aefc60217..c507f2a843 100644 // Copyright 2024-present Datadog, Inc. -//go:build !linux -+//go:build !linux || nonglibc ++//go:build !linux || !glibc package gpu +diff --git a/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml +new file mode 100644 +index 0000000000..e3f1e155e6 +--- /dev/null ++++ b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml +@@ -0,0 +1,7 @@ ++--- ++enhancements: ++ - | ++ Add a build option (`--glibc`) to build the Agent on `glibc` environment. ++ On the other libc environments like `musl`, the Agent should be built without the option. ++ The option enables system-probe gpu module and corechecks gpu collector using ++ `github.com/NVIDIA/go-nvml` which depends on a glibc-extended definition. diff --git a/tasks/agent.py b/tasks/agent.py -index b0220fcb60..bec7654b48 100644 +index 66da958ed9..c20b48ccf8 100644 --- a/tasks/agent.py +++ b/tasks/agent.py -@@ -140,6 +140,7 @@ def build( +@@ -146,6 +146,7 @@ def build( bundle_ebpf=False, agent_bin=None, run_on=None, # noqa: U100, F841. Used by the run_on_devcontainer decorator -+ non_glibc=False, ++ no_glibc=False, ): """ Build the agent. If the bits to include in the build are not specified, -@@ -213,6 +214,9 @@ def build( +@@ -219,6 +220,9 @@ def build( all_tags |= set(build_tags) build_tags = list(all_tags) -+ if non_glibc: -+ build_tags.append("nonglibc") ++ if no_glibc: ++ build_tags = list(set(build_tags).difference({"glibc"})) + cmd = "go build -mod={go_mod} {race_opt} {build_type} -tags \"{go_build_tags}\" " if not agent_bin: +diff --git a/tasks/build_tags.py b/tasks/build_tags.py +index cfcbb3c340..1d88165629 100644 +--- a/tasks/build_tags.py ++++ b/tasks/build_tags.py +@@ -31,6 +31,7 @@ ALL_TAGS = { + "ec2", + "etcd", + "fargateprocess", ++ "glibc", # Build the modules depending on the glibc extension. + "jmx", + "jetson", + "kubeapiserver", +@@ -69,6 +70,7 @@ AGENT_TAGS = { + "docker", + "ec2", + "etcd", ++ "glibc", + "jetson", + "jmx", + "kubeapiserver", +@@ -109,19 +111,19 @@ AGENT_HEROKU_TAGS = AGENT_TAGS.difference( + FIPS_AGENT_TAGS = AGENT_TAGS.union({"goexperiment.systemcrypto"}) + + # CLUSTER_AGENT_TAGS lists the tags needed when building the cluster-agent +-CLUSTER_AGENT_TAGS = {"clusterchecks", "datadog.no_waf", "kubeapiserver", "orchestrator", "zlib", "zstd", "ec2"} ++CLUSTER_AGENT_TAGS = {"clusterchecks", "datadog.no_waf", "glibc", "kubeapiserver", "orchestrator", "zlib", "zstd", "ec2"} + + # CLUSTER_AGENT_CLOUDFOUNDRY_TAGS lists the tags needed when building the cloudfoundry cluster-agent +-CLUSTER_AGENT_CLOUDFOUNDRY_TAGS = {"clusterchecks"} ++CLUSTER_AGENT_CLOUDFOUNDRY_TAGS = {"clusterchecks", "glibc"} + + # DOGSTATSD_TAGS lists the tags needed when building dogstatsd +-DOGSTATSD_TAGS = {"containerd", "no_dynamic_plugins", "docker", "kubelet", "podman", "zlib", "zstd"} ++DOGSTATSD_TAGS = {"containerd", "no_dynamic_plugins", "docker", "glibc", "kubelet", "podman", "zlib", "zstd"} + + # IOT_AGENT_TAGS lists the tags needed when building the IoT agent +-IOT_AGENT_TAGS = {"jetson", "otlp", "systemd", "zlib", "zstd"} ++IOT_AGENT_TAGS = {"glibc", "jetson", "otlp", "systemd", "zlib", "zstd"} + + # INSTALLER_TAGS lists the tags needed when building the installer +-INSTALLER_TAGS = {"docker", "ec2", "kubelet"} ++INSTALLER_TAGS = {"docker", "ec2", "glibc", "kubelet"} + + # PROCESS_AGENT_TAGS lists the tags necessary to build the process-agent + PROCESS_AGENT_TAGS = AGENT_TAGS.union({"fargateprocess"}).difference({"otlp", "python", "trivy"}) +@@ -150,6 +152,7 @@ SECURITY_AGENT_TAGS = { + "datadog.no_waf", + "docker", + "containerd", ++ "glibc", + "no_dynamic_plugins", + "kubeapiserver", + "kubelet", +@@ -160,13 +163,14 @@ SECURITY_AGENT_TAGS = { + } + + # SERVERLESS_TAGS lists the tags necessary to build serverless +-SERVERLESS_TAGS = {"serverless", "otlp"} ++SERVERLESS_TAGS = {"glibc", "serverless", "otlp"} + + # SYSTEM_PROBE_TAGS lists the tags necessary to build system-probe + SYSTEM_PROBE_TAGS = { + "datadog.no_waf", + "no_dynamic_plugins", + "ec2", ++ "glibc", + "linux_bpf", + "netcgo", + "npm", +@@ -182,6 +186,7 @@ TRACE_AGENT_TAGS = { + "containerd", + "no_dynamic_plugins", + "datadog.no_waf", ++ "glibc" + "kubeapiserver", + "kubelet", + "otlp", diff --git a/tasks/system_probe.py b/tasks/system_probe.py -index 5ddffee149..6da208b6d2 100644 +index 53a25237b7..cdfdf9a8a8 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py -@@ -684,10 +684,12 @@ def build( - with_unit_test=False, +@@ -689,6 +689,7 @@ def build( ebpf_compiler='clang', static=False, -+ non_glibc=False, + fips_mode=False, ++ no_glibc=False, ): """ Build the system-probe - """ -+ raise NameError('test') - if not is_macos: - build_object_files( - ctx, -@@ -710,6 +712,7 @@ def build( - strip_binary=strip_binary, +@@ -716,6 +717,7 @@ def build( arch=arch, static=static, -+ non_glibc=non_glibc, + fips_mode=fips_mode, ++ no_glibc=no_glibc, ) -@@ -737,6 +740,7 @@ def build_sysprobe_binary( +@@ -743,6 +745,7 @@ def build_sysprobe_binary( strip_binary=False, fips_mode=False, static=False, -+ non_glibc=False, ++ no_glibc=False, ) -> None: arch_obj = Arch.from_str(arch) -@@ -759,6 +763,9 @@ def build_sysprobe_binary( +@@ -765,6 +768,9 @@ def build_sysprobe_binary( build_tags.extend(["osusergo", "netgo"]) build_tags = list(set(build_tags).difference({"netcgo"})) -+ if non_glibc: -+ build_tags.append("nonglibc") ++ if no_glibc: ++ build_tags = list(set(build_tags).difference({"glibc"})) + if not is_windows and "pcap" in build_tags: build_libpcap(ctx) From 2798e6fbec07e49e8b70fea81e5940a46375bbd5 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 15 Jan 2025 15:50:51 +0900 Subject: [PATCH 5/6] Update patch --- Dockerfile | 2 +- disable-gpu-module.patch | 166 +++++++++++++++++++++++++++++---------- 2 files changed, 125 insertions(+), 43 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7aea7f7..757d8c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -150,7 +150,7 @@ COPY disable-gpu-module.patch / RUN patch -p1 < /disable-gpu-module.patch RUN invoke agent.build \ - --non-glibc \ + --no-glibc \ --exclude-rtloader \ --build-exclude=jmx,kubeapiserver,gce,ec2,orchestrator diff --git a/disable-gpu-module.patch b/disable-gpu-module.patch index bc83c2c..c530513 100644 --- a/disable-gpu-module.patch +++ b/disable-gpu-module.patch @@ -1,3 +1,91 @@ +diff --git a/cmd/system-probe/modules/all_glibc_linux.go b/cmd/system-probe/modules/all_glibc_linux.go +new file mode 100644 +index 0000000000..c6f419f58d +--- /dev/null ++++ b/cmd/system-probe/modules/all_glibc_linux.go +@@ -0,0 +1,38 @@ ++// 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 2016-present Datadog, Inc. ++ ++//go:build linux && !arm64 && glibc ++ ++// Package modules is all the module definitions for system-probe ++package modules ++ ++import ( ++ "time" ++ ++ "github.com/DataDog/datadog-agent/cmd/system-probe/api/module" ++) ++ ++// All System Probe modules should register their factories here ++var All = []module.Factory{ ++ EBPFProbe, ++ NetworkTracer, ++ TCPQueueLength, ++ OOMKillProbe, ++ // there is a dependency from EventMonitor -> NetworkTracer ++ // so EventMonitor has to follow NetworkTracer ++ EventMonitor, ++ Process, ++ DynamicInstrumentation, ++ LanguageDetectionModule, ++ ComplianceModule, ++ Pinger, ++ Traceroute, ++ DiscoveryModule, ++ GPUMonitoring, // GPU monitoring needs to be initialized afer EventMonitor, so that we have the event consumer ready ++} ++ ++func inactivityEventLog(_ time.Duration) { ++ ++} +diff --git a/cmd/system-probe/modules/all_glibc_linux_arm64.go b/cmd/system-probe/modules/all_glibc_linux_arm64.go +new file mode 100644 +index 0000000000..033968300d +--- /dev/null ++++ b/cmd/system-probe/modules/all_glibc_linux_arm64.go +@@ -0,0 +1,38 @@ ++// 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 && arm64 && glibc ++ ++// Package modules is all the module definitions for system-probe ++package modules ++ ++import ( ++ "time" ++ ++ "github.com/DataDog/datadog-agent/cmd/system-probe/api/module" ++) ++ ++// All System Probe modules should register their factories here ++var All = []module.Factory{ ++ EBPFProbe, ++ NetworkTracer, ++ TCPQueueLength, ++ OOMKillProbe, ++ // there is a dependency from EventMonitor -> NetworkTracer ++ // so EventMonitor has to follow NetworkTracer ++ EventMonitor, ++ Process, ++ DynamicInstrumentation, ++ LanguageDetectionModule, ++ ComplianceModule, ++ Pinger, ++ Traceroute, ++ DiscoveryModule, ++ GPUMonitoring, // GPU monitoring needs to be initialized afer EventMonitor, so that we have the event consumer ready ++} ++ ++func inactivityEventLog(_ time.Duration) { ++ ++} diff --git a/cmd/system-probe/modules/all_linux.go b/cmd/system-probe/modules/all_linux.go index 79b6f3d74a..0da0a6818a 100644 --- a/cmd/system-probe/modules/all_linux.go @@ -33,7 +121,7 @@ index e5a81541e5..4c3bc6ba3c 100644 // Package modules is all the module definitions for system-probe package modules diff --git a/cmd/system-probe/modules/gpu.go b/cmd/system-probe/modules/gpu.go -index c7dbac874d..4ef84fb1cf 100644 +index 7ec273e7c2..d009389b1c 100644 --- a/cmd/system-probe/modules/gpu.go +++ b/cmd/system-probe/modules/gpu.go @@ -3,7 +3,7 @@ @@ -46,7 +134,7 @@ index c7dbac874d..4ef84fb1cf 100644 package modules diff --git a/pkg/collector/corechecks/gpu/gpu.go b/pkg/collector/corechecks/gpu/gpu.go -index dbaa9bbc3d..6fd31fcdd5 100644 +index 1083db30ad..c62e07cead 100644 --- a/pkg/collector/corechecks/gpu/gpu.go +++ b/pkg/collector/corechecks/gpu/gpu.go @@ -3,7 +3,7 @@ @@ -59,7 +147,7 @@ index dbaa9bbc3d..6fd31fcdd5 100644 package gpu diff --git a/pkg/collector/corechecks/gpu/gpu_stub.go b/pkg/collector/corechecks/gpu/gpu_stub.go -index 9605813661..51706336f2 100644 +index 5aefc60217..577a4ed494 100644 --- a/pkg/collector/corechecks/gpu/gpu_stub.go +++ b/pkg/collector/corechecks/gpu/gpu_stub.go @@ -3,7 +3,7 @@ @@ -85,10 +173,10 @@ index 0000000000..e3f1e155e6 + The option enables system-probe gpu module and corechecks gpu collector using + `github.com/NVIDIA/go-nvml` which depends on a glibc-extended definition. diff --git a/tasks/agent.py b/tasks/agent.py -index 66da958ed9..c20b48ccf8 100644 +index b0220fcb60..523df6a7b8 100644 --- a/tasks/agent.py +++ b/tasks/agent.py -@@ -146,6 +146,7 @@ def build( +@@ -140,6 +140,7 @@ def build( bundle_ebpf=False, agent_bin=None, run_on=None, # noqa: U100, F841. Used by the run_on_devcontainer decorator @@ -96,7 +184,7 @@ index 66da958ed9..c20b48ccf8 100644 ): """ Build the agent. If the bits to include in the build are not specified, -@@ -219,6 +220,9 @@ def build( +@@ -213,6 +214,9 @@ def build( all_tags |= set(build_tags) build_tags = list(all_tags) @@ -107,59 +195,61 @@ index 66da958ed9..c20b48ccf8 100644 if not agent_bin: diff --git a/tasks/build_tags.py b/tasks/build_tags.py -index cfcbb3c340..1d88165629 100644 +index 81b0564285..190d83ff62 100644 --- a/tasks/build_tags.py +++ b/tasks/build_tags.py -@@ -31,6 +31,7 @@ ALL_TAGS = { +@@ -28,7 +28,7 @@ ALL_TAGS = { "ec2", "etcd", "fargateprocess", +- "gce", + "glibc", # Build the modules depending on the glibc extension. "jmx", "jetson", "kubeapiserver", -@@ -69,6 +70,7 @@ AGENT_TAGS = { +@@ -68,7 +68,7 @@ AGENT_TAGS = { "docker", "ec2", "etcd", +- "gce", + "glibc", "jetson", "jmx", "kubeapiserver", -@@ -109,19 +111,19 @@ AGENT_HEROKU_TAGS = AGENT_TAGS.difference( +@@ -109,19 +109,19 @@ AGENT_HEROKU_TAGS = AGENT_TAGS.difference( FIPS_AGENT_TAGS = AGENT_TAGS.union({"goexperiment.systemcrypto"}) # CLUSTER_AGENT_TAGS lists the tags needed when building the cluster-agent --CLUSTER_AGENT_TAGS = {"clusterchecks", "datadog.no_waf", "kubeapiserver", "orchestrator", "zlib", "zstd", "ec2"} -+CLUSTER_AGENT_TAGS = {"clusterchecks", "datadog.no_waf", "glibc", "kubeapiserver", "orchestrator", "zlib", "zstd", "ec2"} +-CLUSTER_AGENT_TAGS = {"clusterchecks", "datadog.no_waf", "kubeapiserver", "orchestrator", "zlib", "zstd", "ec2", "gce"} ++CLUSTER_AGENT_TAGS = {"clusterchecks", "datadog.no_waf", "glibc", "kubeapiserver", "orchestrator", "zlib", "zstd", "ec2", "gce"} # CLUSTER_AGENT_CLOUDFOUNDRY_TAGS lists the tags needed when building the cloudfoundry cluster-agent -CLUSTER_AGENT_CLOUDFOUNDRY_TAGS = {"clusterchecks"} +CLUSTER_AGENT_CLOUDFOUNDRY_TAGS = {"clusterchecks", "glibc"} # DOGSTATSD_TAGS lists the tags needed when building dogstatsd --DOGSTATSD_TAGS = {"containerd", "no_dynamic_plugins", "docker", "kubelet", "podman", "zlib", "zstd"} -+DOGSTATSD_TAGS = {"containerd", "no_dynamic_plugins", "docker", "glibc", "kubelet", "podman", "zlib", "zstd"} +-DOGSTATSD_TAGS = {"containerd", "docker", "kubelet", "podman", "zlib", "zstd"} ++DOGSTATSD_TAGS = {"containerd", "docker", "glibc", "kubelet", "podman", "zlib", "zstd"} # IOT_AGENT_TAGS lists the tags needed when building the IoT agent -IOT_AGENT_TAGS = {"jetson", "otlp", "systemd", "zlib", "zstd"} +IOT_AGENT_TAGS = {"glibc", "jetson", "otlp", "systemd", "zlib", "zstd"} # INSTALLER_TAGS lists the tags needed when building the installer --INSTALLER_TAGS = {"docker", "ec2", "kubelet"} -+INSTALLER_TAGS = {"docker", "ec2", "glibc", "kubelet"} +-INSTALLER_TAGS = {"docker", "ec2", "gce", "kubelet"} ++INSTALLER_TAGS = {"docker", "ec2", "gce", "glibc", "kubelet"} # PROCESS_AGENT_TAGS lists the tags necessary to build the process-agent PROCESS_AGENT_TAGS = AGENT_TAGS.union({"fargateprocess"}).difference({"otlp", "python", "trivy"}) -@@ -150,6 +152,7 @@ SECURITY_AGENT_TAGS = { +@@ -149,6 +149,7 @@ SECURITY_AGENT_TAGS = { "datadog.no_waf", "docker", "containerd", + "glibc", - "no_dynamic_plugins", "kubeapiserver", "kubelet", -@@ -160,13 +163,14 @@ SECURITY_AGENT_TAGS = { + "podman", +@@ -158,13 +159,13 @@ SECURITY_AGENT_TAGS = { } # SERVERLESS_TAGS lists the tags necessary to build serverless @@ -167,43 +257,35 @@ index cfcbb3c340..1d88165629 100644 +SERVERLESS_TAGS = {"glibc", "serverless", "otlp"} # SYSTEM_PROBE_TAGS lists the tags necessary to build system-probe - SYSTEM_PROBE_TAGS = { - "datadog.no_waf", - "no_dynamic_plugins", - "ec2", -+ "glibc", - "linux_bpf", - "netcgo", - "npm", -@@ -182,6 +186,7 @@ TRACE_AGENT_TAGS = { - "containerd", - "no_dynamic_plugins", - "datadog.no_waf", -+ "glibc" - "kubeapiserver", - "kubelet", - "otlp", + SYSTEM_PROBE_TAGS = AGENT_TAGS.union({"linux_bpf", "npm", "pcap", "remotewmonly"}).difference({"python", "systemd"}) + + # TRACE_AGENT_TAGS lists the tags that have to be added when the trace-agent +-TRACE_AGENT_TAGS = {"docker", "containerd", "datadog.no_waf", "kubeapiserver", "kubelet", "otlp", "netcgo", "podman"} ++TRACE_AGENT_TAGS = {"docker", "containerd", "datadog.no_waf", "glibc", "kubeapiserver", "kubelet", "otlp", "netcgo", "podman"} + + # TRACE_AGENT_HEROKU_TAGS lists the tags necessary to build the trace-agent for Heroku + TRACE_AGENT_HEROKU_TAGS = TRACE_AGENT_TAGS.difference( diff --git a/tasks/system_probe.py b/tasks/system_probe.py -index 53a25237b7..cdfdf9a8a8 100644 +index 5ddffee149..62ae982479 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py -@@ -689,6 +689,7 @@ def build( +@@ -684,6 +684,7 @@ def build( + with_unit_test=False, ebpf_compiler='clang', static=False, - fips_mode=False, + no_glibc=False, ): """ Build the system-probe -@@ -716,6 +717,7 @@ def build( +@@ -710,6 +711,7 @@ def build( + strip_binary=strip_binary, arch=arch, static=static, - fips_mode=fips_mode, + no_glibc=no_glibc, ) -@@ -743,6 +745,7 @@ def build_sysprobe_binary( +@@ -737,6 +739,7 @@ def build_sysprobe_binary( strip_binary=False, fips_mode=False, static=False, @@ -211,7 +293,7 @@ index 53a25237b7..cdfdf9a8a8 100644 ) -> None: arch_obj = Arch.from_str(arch) -@@ -765,6 +768,9 @@ def build_sysprobe_binary( +@@ -759,6 +762,9 @@ def build_sysprobe_binary( build_tags.extend(["osusergo", "netgo"]) build_tags = list(set(build_tags).difference({"netcgo"})) From 34383c1abecc9fe70ad9a8ee71164ea69c7d2670 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Mon, 20 Jan 2025 12:55:00 +0900 Subject: [PATCH 6/6] Update patch --- disable-gpu-module.patch | 146 +++++++++------------------------------ 1 file changed, 32 insertions(+), 114 deletions(-) diff --git a/disable-gpu-module.patch b/disable-gpu-module.patch index c530513..4869a7b 100644 --- a/disable-gpu-module.patch +++ b/disable-gpu-module.patch @@ -1,93 +1,24 @@ -diff --git a/cmd/system-probe/modules/all_glibc_linux.go b/cmd/system-probe/modules/all_glibc_linux.go -new file mode 100644 -index 0000000000..c6f419f58d ---- /dev/null +diff --git a/cmd/system-probe/modules/all_linux_arm64.go b/cmd/system-probe/modules/all_glibc_linux.go +similarity index 93% +rename from cmd/system-probe/modules/all_linux_arm64.go +rename to cmd/system-probe/modules/all_glibc_linux.go +index e5a81541e5..9a4545e769 100644 +--- a/cmd/system-probe/modules/all_linux_arm64.go +++ b/cmd/system-probe/modules/all_glibc_linux.go -@@ -0,0 +1,38 @@ -+// 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/). +@@ -1,9 +1,9 @@ + // 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. +// Copyright 2016-present Datadog, Inc. -+ -+//go:build linux && !arm64 && glibc -+ -+// Package modules is all the module definitions for system-probe -+package modules -+ -+import ( -+ "time" -+ -+ "github.com/DataDog/datadog-agent/cmd/system-probe/api/module" -+) -+ -+// All System Probe modules should register their factories here -+var All = []module.Factory{ -+ EBPFProbe, -+ NetworkTracer, -+ TCPQueueLength, -+ OOMKillProbe, -+ // there is a dependency from EventMonitor -> NetworkTracer -+ // so EventMonitor has to follow NetworkTracer -+ EventMonitor, -+ Process, -+ DynamicInstrumentation, -+ LanguageDetectionModule, -+ ComplianceModule, -+ Pinger, -+ Traceroute, -+ DiscoveryModule, -+ GPUMonitoring, // GPU monitoring needs to be initialized afer EventMonitor, so that we have the event consumer ready -+} -+ -+func inactivityEventLog(_ time.Duration) { -+ -+} -diff --git a/cmd/system-probe/modules/all_glibc_linux_arm64.go b/cmd/system-probe/modules/all_glibc_linux_arm64.go -new file mode 100644 -index 0000000000..033968300d ---- /dev/null -+++ b/cmd/system-probe/modules/all_glibc_linux_arm64.go -@@ -0,0 +1,38 @@ -+// 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 && arm64 && glibc -+ -+// Package modules is all the module definitions for system-probe -+package modules -+ -+import ( -+ "time" -+ -+ "github.com/DataDog/datadog-agent/cmd/system-probe/api/module" -+) -+ -+// All System Probe modules should register their factories here -+var All = []module.Factory{ -+ EBPFProbe, -+ NetworkTracer, -+ TCPQueueLength, -+ OOMKillProbe, -+ // there is a dependency from EventMonitor -> NetworkTracer -+ // so EventMonitor has to follow NetworkTracer -+ EventMonitor, -+ Process, -+ DynamicInstrumentation, -+ LanguageDetectionModule, -+ ComplianceModule, -+ Pinger, -+ Traceroute, -+ DiscoveryModule, -+ GPUMonitoring, // GPU monitoring needs to be initialized afer EventMonitor, so that we have the event consumer ready -+} -+ -+func inactivityEventLog(_ time.Duration) { -+ -+} + +-//go:build linux && arm64 ++//go:build linux && glibc + + // Package modules is all the module definitions for system-probe + package modules diff --git a/cmd/system-probe/modules/all_linux.go b/cmd/system-probe/modules/all_linux.go -index 79b6f3d74a..0da0a6818a 100644 +index 79b6f3d74a..24fb877689 100644 --- a/cmd/system-probe/modules/all_linux.go +++ b/cmd/system-probe/modules/all_linux.go @@ -3,7 +3,7 @@ @@ -95,7 +26,7 @@ index 79b6f3d74a..0da0a6818a 100644 // Copyright 2016-present Datadog, Inc. -//go:build linux && !arm64 -+//go:build linux && !arm64 && !glibc ++//go:build linux && !glibc // Package modules is all the module definitions for system-probe package modules @@ -107,21 +38,8 @@ index 79b6f3d74a..0da0a6818a 100644 } func inactivityEventLog(_ time.Duration) { -diff --git a/cmd/system-probe/modules/all_linux_arm64.go b/cmd/system-probe/modules/all_linux_arm64.go -index e5a81541e5..4c3bc6ba3c 100644 ---- a/cmd/system-probe/modules/all_linux_arm64.go -+++ b/cmd/system-probe/modules/all_linux_arm64.go -@@ -3,7 +3,7 @@ - // This product includes software developed at Datadog (https://www.datadoghq.com/). - // Copyright 2024-present Datadog, Inc. - --//go:build linux && arm64 -+//go:build linux && arm64 && !glibc - - // Package modules is all the module definitions for system-probe - package modules diff --git a/cmd/system-probe/modules/gpu.go b/cmd/system-probe/modules/gpu.go -index 7ec273e7c2..d009389b1c 100644 +index 7ec273e7c2..47b4f3991f 100644 --- a/cmd/system-probe/modules/gpu.go +++ b/cmd/system-probe/modules/gpu.go @@ -3,7 +3,7 @@ @@ -129,7 +47,7 @@ index 7ec273e7c2..d009389b1c 100644 // Copyright 2024-present Datadog, Inc. -//go:build linux -+//go:build linux && !nonglibc ++//go:build linux && glibc package modules @@ -161,26 +79,26 @@ index 5aefc60217..577a4ed494 100644 diff --git a/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml new file mode 100644 -index 0000000000..e3f1e155e6 +index 0000000000..2a873b9f03 --- /dev/null +++ b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml @@ -0,0 +1,7 @@ +--- +enhancements: + - | -+ Add a build option (`--glibc`) to build the Agent on `glibc` environment. -+ On the other libc environments like `musl`, the Agent should be built without the option. ++ Add a build option (`--glibc`, enabled by default) to build the Agent on `glibc` environment. ++ On the other libc environments like `musl`, the Agent should be built with `--no-glibc` option. + The option enables system-probe gpu module and corechecks gpu collector using + `github.com/NVIDIA/go-nvml` which depends on a glibc-extended definition. diff --git a/tasks/agent.py b/tasks/agent.py -index b0220fcb60..523df6a7b8 100644 +index b0220fcb60..ae6b80def5 100644 --- a/tasks/agent.py +++ b/tasks/agent.py @@ -140,6 +140,7 @@ def build( bundle_ebpf=False, agent_bin=None, run_on=None, # noqa: U100, F841. Used by the run_on_devcontainer decorator -+ no_glibc=False, ++ glibc=True, ): """ Build the agent. If the bits to include in the build are not specified, @@ -188,7 +106,7 @@ index b0220fcb60..523df6a7b8 100644 all_tags |= set(build_tags) build_tags = list(all_tags) -+ if no_glibc: ++ if not glibc: + build_tags = list(set(build_tags).difference({"glibc"})) + cmd = "go build -mod={go_mod} {race_opt} {build_type} -tags \"{go_build_tags}\" " @@ -266,14 +184,14 @@ index 81b0564285..190d83ff62 100644 # TRACE_AGENT_HEROKU_TAGS lists the tags necessary to build the trace-agent for Heroku TRACE_AGENT_HEROKU_TAGS = TRACE_AGENT_TAGS.difference( diff --git a/tasks/system_probe.py b/tasks/system_probe.py -index 5ddffee149..62ae982479 100644 +index 5ddffee149..bbc237bcf4 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py @@ -684,6 +684,7 @@ def build( with_unit_test=False, ebpf_compiler='clang', static=False, -+ no_glibc=False, ++ glibc=True, ): """ Build the system-probe @@ -281,7 +199,7 @@ index 5ddffee149..62ae982479 100644 strip_binary=strip_binary, arch=arch, static=static, -+ no_glibc=no_glibc, ++ glibc=glibc, ) @@ -289,7 +207,7 @@ index 5ddffee149..62ae982479 100644 strip_binary=False, fips_mode=False, static=False, -+ no_glibc=False, ++ glibc=True, ) -> None: arch_obj = Arch.from_str(arch) @@ -297,7 +215,7 @@ index 5ddffee149..62ae982479 100644 build_tags.extend(["osusergo", "netgo"]) build_tags = list(set(build_tags).difference({"netcgo"})) -+ if no_glibc: ++ if not glibc: + build_tags = list(set(build_tags).difference({"glibc"})) + if not is_windows and "pcap" in build_tags: