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 e5a81541e5896..9a4545e769888 100644 --- a/cmd/system-probe/modules/all_linux_arm64.go +++ b/cmd/system-probe/modules/all_glibc_linux.go @@ -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 +//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 79b6f3d74afec..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 +//go:build linux && !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/gpu.go b/cmd/system-probe/modules/gpu.go index c7dbac874dccd..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 +//go:build linux && glibc package modules diff --git a/pkg/collector/corechecks/gpu/gpu.go b/pkg/collector/corechecks/gpu/gpu.go index dbaa9bbc3dd00..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 +//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 9605813661b91..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 +//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 0000000000000..2a873b9f03b2f --- /dev/null +++ b/releasenotes/notes/add-option-to-disable-gpu-module-3301f07d73244d06.yaml @@ -0,0 +1,7 @@ +--- +enhancements: + - | + 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 66da958ed93f2..a405993848460 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 + glibc=True, ): """ 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 not 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 cfcbb3c340ece..7a850beb29be9 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,28 @@ 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 +161,7 @@ "datadog.no_waf", "docker", "containerd", + "glibc", "no_dynamic_plugins", "kubeapiserver", "kubelet", @@ -160,13 +172,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 +195,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 53a25237b7e2a..2a8510a0001d7 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py @@ -689,6 +689,7 @@ def build( ebpf_compiler='clang', static=False, fips_mode=False, + glibc=True, ): """ Build the system-probe @@ -716,6 +717,7 @@ def build( arch=arch, static=static, fips_mode=fips_mode, + glibc=glibc, ) @@ -743,6 +745,7 @@ def build_sysprobe_binary( strip_binary=False, fips_mode=False, static=False, + glibc=True, ) -> None: arch_obj = Arch.from_str(arch) @@ -765,6 +768,9 @@ def build_sysprobe_binary( build_tags.extend(["osusergo", "netgo"]) build_tags = list(set(build_tags).difference({"netcgo"})) + if not glibc: + build_tags = list(set(build_tags).difference({"glibc"})) + if not is_windows and "pcap" in build_tags: build_libpcap(ctx) cgo_flags = get_libpcap_cgo_flags(ctx, install_path)