From 863c16843cb19db5f08e2214084d5e10f083d81e Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Tue, 14 Jan 2025 14:25:44 +0900 Subject: [PATCH 01/11] Add option to build on non-glibc env Add an build option (`--non-glibc`) to build the agent on non-glibc environment like musl libc. The option disables system-probe gpu module and corechecks gpu collector using `github.com/NVIDIA/go-nvml` which depends on a glibc-extended definition. --- cmd/system-probe/modules/all_linux.go | 2 +- cmd/system-probe/modules/all_linux_arm64.go | 2 +- .../modules/all_nonglibc_linux.go | 37 ++++++++++++++++++ .../modules/all_nonglibc_linux_arm64.go | 38 +++++++++++++++++++ cmd/system-probe/modules/gpu.go | 2 +- pkg/collector/corechecks/gpu/gpu.go | 2 +- pkg/collector/corechecks/gpu/gpu_stub.go | 2 +- ...o-disable-gpu-module-3301f07d73244d06.yaml | 6 +++ tasks/agent.py | 4 ++ tasks/system_probe.py | 7 ++++ 10 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 cmd/system-probe/modules/all_nonglibc_linux.go create mode 100644 cmd/system-probe/modules/all_nonglibc_linux_arm64.go create mode 100644 releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml diff --git a/cmd/system-probe/modules/all_linux.go b/cmd/system-probe/modules/all_linux.go index 79b6f3d74afec..75198e4b508ca 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 e5a81541e5896..663d2c804f830 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/all_nonglibc_linux.go b/cmd/system-probe/modules/all_nonglibc_linux.go new file mode 100644 index 0000000000000..2f68a14a4a87b --- /dev/null +++ b/cmd/system-probe/modules/all_nonglibc_linux.go @@ -0,0 +1,37 @@ +// 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 && nonglibc + +// 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, +} + +func inactivityEventLog(_ time.Duration) { + +} diff --git a/cmd/system-probe/modules/all_nonglibc_linux_arm64.go b/cmd/system-probe/modules/all_nonglibc_linux_arm64.go new file mode 100644 index 0000000000000..d0aa1206d3a16 --- /dev/null +++ b/cmd/system-probe/modules/all_nonglibc_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 && nonglibc + +// 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/gpu.go b/cmd/system-probe/modules/gpu.go index c7dbac874dccd..4ef84fb1cf918 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 dbaa9bbc3dd00..c32d2a437e4fa 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 9605813661b91..8dd82c3f356b0 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/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 0000000000000..490a1bb228677 --- /dev/null +++ b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml @@ -0,0 +1,6 @@ +--- +enhancements: + - | + Add an build option (`--non-glibc`) to build the agent on non-glibc environment like musl libc. + The option disables 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 66da958ed93f2..d6aba0e05387d 100644 --- a/tasks/agent.py +++ b/tasks/agent.py @@ -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, ): """ Build the agent. If the bits to include in the build are not specified, @@ -219,6 +220,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 53a25237b7e2a..4e44b21e9f8d7 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py @@ -689,10 +689,12 @@ def build( ebpf_compiler='clang', static=False, fips_mode=False, + non_glibc=False, ): """ Build the system-probe """ + raise NameError('test') if not is_macos: build_object_files( ctx, @@ -716,6 +718,7 @@ def build( arch=arch, static=static, fips_mode=fips_mode, + non_glibc=non_glibc, ) @@ -743,6 +746,7 @@ def build_sysprobe_binary( strip_binary=False, fips_mode=False, static=False, + non_glibc=False, ) -> None: arch_obj = Arch.from_str(arch) @@ -765,6 +769,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 e72ad7acd6eb4be3cd7b075497a0a3791cb731e9 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 15 Jan 2025 14:36:26 +0900 Subject: [PATCH 02/11] Remove debug exception --- tasks/system_probe.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/system_probe.py b/tasks/system_probe.py index 4e44b21e9f8d7..f98012cb0cc1c 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py @@ -694,7 +694,6 @@ def build( """ Build the system-probe """ - raise NameError('test') if not is_macos: build_object_files( ctx, From 1055f264c25f4569f4b039c741508e98f0718696 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 15 Jan 2025 14:54:57 +0900 Subject: [PATCH 03/11] Update release note --- .../add-option-to-disable-gpu-module-3301f07d73244d06.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml index 490a1bb228677..70f568ddfaaa2 100644 --- a/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml +++ b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml @@ -1,6 +1,6 @@ --- enhancements: - | - Add an build option (`--non-glibc`) to build the agent on non-glibc environment like musl libc. + Add an build option (`--non-glibc`) to build the Agent on `non-glibc` environment like musl libc. The option disables system-probe gpu module and corechecks gpu collector using `github.com/NVIDIA/go-nvml` which depends on a glibc-extended definition. From 5cd61021296ad376b7928c0bad87d42ce4e3fd76 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 15 Jan 2025 15:44:06 +0900 Subject: [PATCH 04/11] Invert build tag logic --- ...all_nonglibc_linux.go => all_glibc_linux.go} | 3 ++- ..._linux_arm64.go => all_glibc_linux_arm64.go} | 2 +- cmd/system-probe/modules/all_linux.go | 3 +-- cmd/system-probe/modules/all_linux_arm64.go | 2 +- pkg/collector/corechecks/gpu/gpu.go | 2 +- pkg/collector/corechecks/gpu/gpu_stub.go | 2 +- ...-to-disable-gpu-module-3301f07d73244d06.yaml | 5 +++-- tasks/agent.py | 6 +++--- tasks/build_tags.py | 17 +++++++++++------ tasks/system_probe.py | 10 +++++----- 10 files changed, 29 insertions(+), 23 deletions(-) rename cmd/system-probe/modules/{all_nonglibc_linux.go => all_glibc_linux.go} (84%) rename cmd/system-probe/modules/{all_nonglibc_linux_arm64.go => all_glibc_linux_arm64.go} (96%) diff --git a/cmd/system-probe/modules/all_nonglibc_linux.go b/cmd/system-probe/modules/all_glibc_linux.go similarity index 84% rename from cmd/system-probe/modules/all_nonglibc_linux.go rename to cmd/system-probe/modules/all_glibc_linux.go index 2f68a14a4a87b..c6f419f58d48f 100644 --- a/cmd/system-probe/modules/all_nonglibc_linux.go +++ b/cmd/system-probe/modules/all_glibc_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 && nonglibc +//go:build linux && !arm64 && glibc // Package modules is all the module definitions for system-probe package modules @@ -30,6 +30,7 @@ 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_nonglibc_linux_arm64.go b/cmd/system-probe/modules/all_glibc_linux_arm64.go similarity index 96% rename from cmd/system-probe/modules/all_nonglibc_linux_arm64.go rename to cmd/system-probe/modules/all_glibc_linux_arm64.go index d0aa1206d3a16..033968300de44 100644 --- a/cmd/system-probe/modules/all_nonglibc_linux_arm64.go +++ b/cmd/system-probe/modules/all_glibc_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 && 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/all_linux.go b/cmd/system-probe/modules/all_linux.go index 75198e4b508ca..0da0a6818ae61 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 && !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 663d2c804f830..4c3bc6ba3c8b6 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 && !nonglibc +//go:build linux && arm64 && !glibc // Package modules is all the module definitions for system-probe package modules diff --git a/pkg/collector/corechecks/gpu/gpu.go b/pkg/collector/corechecks/gpu/gpu.go index c32d2a437e4fa..6fd31fcdd5e11 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 && !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 8dd82c3f356b0..51706336f24f8 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 || 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 index 70f568ddfaaa2..e3f1e155e6bb6 100644 --- a/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml +++ b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml @@ -1,6 +1,7 @@ --- enhancements: - | - Add an build option (`--non-glibc`) to build the Agent on `non-glibc` environment like musl libc. - The option disables system-probe gpu module and corechecks gpu collector using + 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 d6aba0e05387d..c20b48ccf89c6 100644 --- a/tasks/agent.py +++ b/tasks/agent.py @@ -146,7 +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, @@ -220,8 +220,8 @@ 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}\" " diff --git a/tasks/build_tags.py b/tasks/build_tags.py index cfcbb3c340ece..1d881656294ca 100644 --- a/tasks/build_tags.py +++ b/tasks/build_tags.py @@ -31,6 +31,7 @@ "ec2", "etcd", "fargateprocess", + "glibc", # Build the modules depending on the glibc extension. "jmx", "jetson", "kubeapiserver", @@ -69,6 +70,7 @@ "docker", "ec2", "etcd", + "glibc", "jetson", "jmx", "kubeapiserver", @@ -109,19 +111,19 @@ 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 @@ "datadog.no_waf", "docker", "containerd", + "glibc", "no_dynamic_plugins", "kubeapiserver", "kubelet", @@ -160,13 +163,14 @@ } # 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 @@ "containerd", "no_dynamic_plugins", "datadog.no_waf", + "glibc" "kubeapiserver", "kubelet", "otlp", diff --git a/tasks/system_probe.py b/tasks/system_probe.py index f98012cb0cc1c..cdfdf9a8a8c3f 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py @@ -689,7 +689,7 @@ def build( ebpf_compiler='clang', static=False, fips_mode=False, - non_glibc=False, + no_glibc=False, ): """ Build the system-probe @@ -717,7 +717,7 @@ def build( arch=arch, static=static, fips_mode=fips_mode, - non_glibc=non_glibc, + no_glibc=no_glibc, ) @@ -745,7 +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) @@ -768,8 +768,8 @@ 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 dc8f47fbf7ea7306a1db169f260bb90a4ab1afc5 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Mon, 20 Jan 2025 12:27:01 +0900 Subject: [PATCH 05/11] Fix build tag --- cmd/system-probe/modules/gpu.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/system-probe/modules/gpu.go b/cmd/system-probe/modules/gpu.go index 4ef84fb1cf918..4eef81be11885 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 && !nonglibc +//go:build linux && glibc package modules From e54d2acebb1c74df8bff12b79d6e0c85b97613af Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Mon, 20 Jan 2025 12:29:43 +0900 Subject: [PATCH 06/11] Fix invoke argument logic --- tasks/agent.py | 4 ++-- tasks/system_probe.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/agent.py b/tasks/agent.py index c20b48ccf89c6..a405993848460 100644 --- a/tasks/agent.py +++ b/tasks/agent.py @@ -146,7 +146,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, @@ -220,7 +220,7 @@ def build( 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}\" " diff --git a/tasks/system_probe.py b/tasks/system_probe.py index cdfdf9a8a8c3f..2a8510a0001d7 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py @@ -689,7 +689,7 @@ def build( ebpf_compiler='clang', static=False, fips_mode=False, - no_glibc=False, + glibc=True, ): """ Build the system-probe @@ -717,7 +717,7 @@ def build( arch=arch, static=static, fips_mode=fips_mode, - no_glibc=no_glibc, + glibc=glibc, ) @@ -745,7 +745,7 @@ def build_sysprobe_binary( strip_binary=False, fips_mode=False, static=False, - no_glibc=False, + glibc=True, ) -> None: arch_obj = Arch.from_str(arch) @@ -768,7 +768,7 @@ def build_sysprobe_binary( 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: From b66fa307308ecdea256745b7537bf2f38bbabbe5 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Mon, 20 Jan 2025 12:31:29 +0900 Subject: [PATCH 07/11] Remove GPUMonitoring module from all_linux_arm64 --- cmd/system-probe/modules/all_linux_arm64.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/system-probe/modules/all_linux_arm64.go b/cmd/system-probe/modules/all_linux_arm64.go index 4c3bc6ba3c8b6..ce771623f4b35 100644 --- a/cmd/system-probe/modules/all_linux_arm64.go +++ b/cmd/system-probe/modules/all_linux_arm64.go @@ -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) { From e9a83ccaad20b4c147436bc04739f7ed6004b2c8 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Mon, 20 Jan 2025 12:38:41 +0900 Subject: [PATCH 08/11] Remove redundant module config files --- cmd/system-probe/modules/all_glibc_linux.go | 2 +- .../modules/all_glibc_linux_arm64.go | 38 ------------------- cmd/system-probe/modules/all_linux.go | 2 +- cmd/system-probe/modules/all_linux_arm64.go | 37 ------------------ 4 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 cmd/system-probe/modules/all_glibc_linux_arm64.go delete mode 100644 cmd/system-probe/modules/all_linux_arm64.go diff --git a/cmd/system-probe/modules/all_glibc_linux.go b/cmd/system-probe/modules/all_glibc_linux.go index c6f419f58d48f..9a4545e769888 100644 --- a/cmd/system-probe/modules/all_glibc_linux.go +++ b/cmd/system-probe/modules/all_glibc_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 && glibc +//go:build linux && glibc // Package modules is all the module definitions for system-probe package modules diff --git a/cmd/system-probe/modules/all_glibc_linux_arm64.go b/cmd/system-probe/modules/all_glibc_linux_arm64.go deleted file mode 100644 index 033968300de44..0000000000000 --- a/cmd/system-probe/modules/all_glibc_linux_arm64.go +++ /dev/null @@ -1,38 +0,0 @@ -// 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 0da0a6818ae61..24fb877689cf2 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 && !glibc +//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_arm64.go b/cmd/system-probe/modules/all_linux_arm64.go deleted file mode 100644 index ce771623f4b35..0000000000000 --- a/cmd/system-probe/modules/all_linux_arm64.go +++ /dev/null @@ -1,37 +0,0 @@ -// 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, -} - -func inactivityEventLog(_ time.Duration) { - -} From 3325bd35583a07b8d4fcfe38646ea1dbf1f0ff20 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Mon, 20 Jan 2025 12:53:49 +0900 Subject: [PATCH 09/11] Update release note --- .../add-option-to-disable-gpu-module-3301f07d73244d06.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml index e3f1e155e6bb6..2a873b9f03b2f 100644 --- a/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml +++ b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml @@ -1,7 +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. From b1bdd17e8ac3e17679023aa4584b979ea9ab4188 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 22 Jan 2025 10:11:33 +0900 Subject: [PATCH 10/11] Fix comma in TRACE_AGENT_TAGS --- tasks/build_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/build_tags.py b/tasks/build_tags.py index 1d881656294ca..cbfee725ecf8b 100644 --- a/tasks/build_tags.py +++ b/tasks/build_tags.py @@ -186,7 +186,7 @@ "containerd", "no_dynamic_plugins", "datadog.no_waf", - "glibc" + "glibc", "kubeapiserver", "kubelet", "otlp", From b5ea6b656a916160354c03393d6ee96809bcdc3b Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 22 Jan 2025 10:13:30 +0900 Subject: [PATCH 11/11] Fix python lint error Co-authored-by: Bryce Kahle --- tasks/build_tags.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tasks/build_tags.py b/tasks/build_tags.py index cbfee725ecf8b..7a850beb29be9 100644 --- a/tasks/build_tags.py +++ b/tasks/build_tags.py @@ -111,7 +111,16 @@ 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", "glibc", "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", "glibc"}