From a4bd36312739f91b3e74ce06cf00c9368d3fa1ee Mon Sep 17 00:00:00 2001 From: Jeremy Hanna Date: Wed, 15 Oct 2025 11:36:02 -0400 Subject: [PATCH 1/7] Default to use the networkv2 checks for Windows and Linux in config setup --- pkg/config/setup/config.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkg/config/setup/config.go b/pkg/config/setup/config.go index bdba5622cef9ae..88674d43e40905 100644 --- a/pkg/config/setup/config.go +++ b/pkg/config/setup/config.go @@ -334,20 +334,24 @@ func InitConfig(config pkgconfigmodel.Setup) { // Otherwise, Python is loaded when the collector is initialized. config.BindEnvAndSetDefault("python_lazy_loading", true) - // If false, the core check will be skipped. - config.BindEnvAndSetDefault("disk_check.use_core_loader", false) - config.BindEnvAndSetDefault("network_check.use_core_loader", false) - // If true, then the go loader will be prioritized over the python loader. config.BindEnvAndSetDefault("prioritize_go_check_loader", true) // If true, then new version of disk v2 check will be used. - // Otherwise, the old version of disk check will be used (maintaining backward compatibility). - config.BindEnvAndSetDefault("use_diskv2_check", false) + // Otherwise, the python version of disk check will be used. + config.BindEnvAndSetDefault("use_diskv2_check", true) + config.BindEnvAndSetDefault("disk_check.use_core_loader", true) - // If true, then new version of network v2 check will be used. - // Otherwise, the old version of network check will be used (maintaining backward compatibility). - config.BindEnvAndSetDefault("use_networkv2_check", false) + // the darwin network and check has not been ported from python + if runtime.GOOS == "darwin" { + config.BindEnvAndSetDefault("use_networkv2_check", false) + config.BindEnvAndSetDefault("network_check.use_core_loader", false) + } else { + // If true, then new version of network v2 check will be used. + // Otherwise, the python version of network check will be used. + config.BindEnvAndSetDefault("use_networkv2_check", true) + config.BindEnvAndSetDefault("network_check.use_core_loader", true) + } // if/when the default is changed to true, make the default platform // dependent; default should remain false on Windows to maintain backward From 73f995424a16fc339c356cd167b315ff2336ec80 Mon Sep 17 00:00:00 2001 From: Jeremy Hanna Date: Wed, 15 Oct 2025 11:38:07 -0400 Subject: [PATCH 2/7] Default to use the networkv2 checks for Windows and Linux in config setup --- pkg/config/setup/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/config/setup/config.go b/pkg/config/setup/config.go index 517ce8a62ea233..52609d8a98dd73 100644 --- a/pkg/config/setup/config.go +++ b/pkg/config/setup/config.go @@ -342,14 +342,14 @@ func InitConfig(config pkgconfigmodel.Setup) { config.BindEnvAndSetDefault("disk_check.use_core_loader", true) // the darwin network and check has not been ported from python - if runtime.GOOS == "darwin" { - config.BindEnvAndSetDefault("use_networkv2_check", false) - config.BindEnvAndSetDefault("network_check.use_core_loader", false) - } else { + if runtime.GOOS == "linux" || runtime.GOOS == "windows" { // If true, then new version of network v2 check will be used. // Otherwise, the python version of network check will be used. config.BindEnvAndSetDefault("use_networkv2_check", true) config.BindEnvAndSetDefault("network_check.use_core_loader", true) + } else { + config.BindEnvAndSetDefault("use_networkv2_check", false) + config.BindEnvAndSetDefault("network_check.use_core_loader", false) } // if/when the default is changed to true, make the default platform From 0d0800ed28739428028587b3ba5576da95bf7df1 Mon Sep 17 00:00:00 2001 From: Jeremy Hanna Date: Wed, 15 Oct 2025 12:24:27 -0400 Subject: [PATCH 3/7] Add enhancement CHANGELOG entry for go core checks --- ...e-v2-checks-by-default-ff71cdcb4455bd43.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 releasenotes/notes/enable-v2-checks-by-default-ff71cdcb4455bd43.yaml diff --git a/releasenotes/notes/enable-v2-checks-by-default-ff71cdcb4455bd43.yaml b/releasenotes/notes/enable-v2-checks-by-default-ff71cdcb4455bd43.yaml new file mode 100644 index 00000000000000..b0bef100628c8f --- /dev/null +++ b/releasenotes/notes/enable-v2-checks-by-default-ff71cdcb4455bd43.yaml @@ -0,0 +1,17 @@ +# Each section from every release note are combined when the +# CHANGELOG.rst is rendered. So the text needs to be worded so that +# it does not depend on any information only available in another +# section. This may mean repeating some details, but each section +# must be readable independently of the other. +# +# Each section note must be formatted as reStructuredText. +--- +enhancements: + - | + Enable the Go disk and network core checks by default for Windows and Linux. + These are direct ports of the existing Python disk and network checks and allow + the Python runtime to be lazy loaded when other integrations are enabled. It + can be disabled with setting ``use_diskv2_check`` and ``use_networkv2_check`` + respectively along with the loader in your configuration to use the Python + version. + From 25bf10d95f9f43f31210dba8e4491e79780f6b00 Mon Sep 17 00:00:00 2001 From: Jeremy Hanna Date: Thu, 16 Oct 2025 17:21:59 -0400 Subject: [PATCH 4/7] Fix failing unit test around new default values --- pkg/collector/corechecks/system/disk/diskv2/disk_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/collector/corechecks/system/disk/diskv2/disk_test.go b/pkg/collector/corechecks/system/disk/diskv2/disk_test.go index 79f195a7684ac1..afc2794d43ff51 100644 --- a/pkg/collector/corechecks/system/disk/diskv2/disk_test.go +++ b/pkg/collector/corechecks/system/disk/diskv2/disk_test.go @@ -1360,6 +1360,7 @@ func TestDiskCheckWithoutCoreLoader(t *testing.T) { cfg := configmock.New(t) cfg.Set("disk_check.use_core_loader", false, configmodel.SourceAgentRuntime) + cfg.Set("use_diskv2_check", false, configmodel.SourceAgentRuntime) diskFactory := diskv2.Factory() diskCheckFunc, ok := diskFactory.Get() From e1e140c9132ff517f3497f1826a3ab96f91d0847 Mon Sep 17 00:00:00 2001 From: Jeremy Hanna Date: Fri, 17 Oct 2025 15:14:39 -0400 Subject: [PATCH 5/7] Set python_lazy_loading to false for e2e tests and make status reflect lazy loading --- pkg/collector/python/version_nopy.go | 19 +++++++++++++++++++ .../python/{version.go => version_python.go} | 4 +++- pkg/collector/python/version_test.go | 6 ++++-- .../agent-platform/common/agent_behaviour.go | 1 + 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 pkg/collector/python/version_nopy.go rename pkg/collector/python/{version.go => version_python.go} (96%) diff --git a/pkg/collector/python/version_nopy.go b/pkg/collector/python/version_nopy.go new file mode 100644 index 00000000000000..da3310f6c3c998 --- /dev/null +++ b/pkg/collector/python/version_nopy.go @@ -0,0 +1,19 @@ +// 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 !python + +// Package python implements the layer to interact with the Python interpreter. +package python + +// GetPythonInfo returns the info string as provided by the embedded Python interpreter which is "n/a" because the agent was built without python. +func GetPythonInfo() string { + return "n/a" +} + +// GetPythonVersion returns nothing here because the agent was built without python. +func GetPythonVersion() string { + return GetPythonInfo() +} diff --git a/pkg/collector/python/version.go b/pkg/collector/python/version_python.go similarity index 96% rename from pkg/collector/python/version.go rename to pkg/collector/python/version_python.go index 4f52aca72cfdca..76babf64de5847 100644 --- a/pkg/collector/python/version.go +++ b/pkg/collector/python/version_python.go @@ -3,6 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. +//go:build python + // Package python implements the layer to interact with the Python interpreter. package python @@ -25,7 +27,7 @@ func GetPythonInfo() string { return x.(string) } - return "n/a" + return "unused" } // GetPythonVersion returns the embedded python version as provided by the embedded Python interpreter. diff --git a/pkg/collector/python/version_test.go b/pkg/collector/python/version_test.go index 0bebd69dcc5bea..43bbfdf38fa83d 100644 --- a/pkg/collector/python/version_test.go +++ b/pkg/collector/python/version_test.go @@ -3,6 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. +//go:build python + package python import ( @@ -20,7 +22,7 @@ func TestGetPythonInfo(t *testing.T) { } func TestGetPythonInfoNoSet(t *testing.T) { - require.Equal(t, "n/a", GetPythonInfo()) + require.Equal(t, "unused", GetPythonInfo()) } func TestGetPythonVersion(t *testing.T) { @@ -30,5 +32,5 @@ func TestGetPythonVersion(t *testing.T) { } func TestGetPythonVersionNotSet(t *testing.T) { - require.Equal(t, "n/a", GetPythonVersion()) + require.Equal(t, "unused", GetPythonVersion()) } diff --git a/test/new-e2e/tests/agent-platform/common/agent_behaviour.go b/test/new-e2e/tests/agent-platform/common/agent_behaviour.go index a1e7baa21417f4..8e8cb2d4110080 100644 --- a/test/new-e2e/tests/agent-platform/common/agent_behaviour.go +++ b/test/new-e2e/tests/agent-platform/common/agent_behaviour.go @@ -230,6 +230,7 @@ func SetAgentPythonMajorVersion(t *testing.T, client *TestClient, majorVersion s t.Run(fmt.Sprintf("set python version %s and restarts", majorVersion), func(tt *testing.T) { configFilePath := client.Helper.GetConfigFolder() + client.Helper.GetConfigFileName() err := client.SetConfig(configFilePath, "python_version", majorVersion) + err := client.SetConfig(configFilePath, "python_lazy_loading", "false") require.NoError(tt, err, "failed to set python version: ", err) _, err = client.SvcManager.Restart(client.Helper.GetServiceName()) From 7f50dc6b756fc50087113a2c66c0e3af1398a48b Mon Sep 17 00:00:00 2001 From: Jeremy Hanna Date: Fri, 17 Oct 2025 16:05:59 -0400 Subject: [PATCH 6/7] Fix linting error --- test/new-e2e/tests/agent-platform/common/agent_behaviour.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/new-e2e/tests/agent-platform/common/agent_behaviour.go b/test/new-e2e/tests/agent-platform/common/agent_behaviour.go index 8e8cb2d4110080..53631c4921915b 100644 --- a/test/new-e2e/tests/agent-platform/common/agent_behaviour.go +++ b/test/new-e2e/tests/agent-platform/common/agent_behaviour.go @@ -230,8 +230,9 @@ func SetAgentPythonMajorVersion(t *testing.T, client *TestClient, majorVersion s t.Run(fmt.Sprintf("set python version %s and restarts", majorVersion), func(tt *testing.T) { configFilePath := client.Helper.GetConfigFolder() + client.Helper.GetConfigFileName() err := client.SetConfig(configFilePath, "python_version", majorVersion) - err := client.SetConfig(configFilePath, "python_lazy_loading", "false") require.NoError(tt, err, "failed to set python version: ", err) + err = client.SetConfig(configFilePath, "python_lazy_loading", "false") + require.NoError(tt, err, "failed to disable python lazy loading", err) _, err = client.SvcManager.Restart(client.Helper.GetServiceName()) require.NoError(tt, err, "agent should be able to restart after editing python version") From e89899a6d26be0839df366273c706237b15ff40a Mon Sep 17 00:00:00 2001 From: Jeremy Hanna Date: Fri, 17 Oct 2025 16:20:40 -0400 Subject: [PATCH 7/7] Updates from PR comments --- .../corechecks/system/disk/diskv2/disk_test.go | 17 ----------------- pkg/config/setup/config.go | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/pkg/collector/corechecks/system/disk/diskv2/disk_test.go b/pkg/collector/corechecks/system/disk/diskv2/disk_test.go index afc2794d43ff51..b802a2973fa4cd 100644 --- a/pkg/collector/corechecks/system/disk/diskv2/disk_test.go +++ b/pkg/collector/corechecks/system/disk/diskv2/disk_test.go @@ -1355,23 +1355,6 @@ func TestGivenADiskCheckWithDefaultConfig_WhenUsagePartitionTimeout_ThenUsageMet m.AssertNotCalled(t, "Gauge", "system.disk.in_use", mock.AnythingOfType("float64"), mock.AnythingOfType("string"), mock.AnythingOfType("[]string")) } -func TestDiskCheckWithoutCoreLoader(t *testing.T) { - flavor.SetTestFlavor(t, flavor.DefaultAgent) - - cfg := configmock.New(t) - cfg.Set("disk_check.use_core_loader", false, configmodel.SourceAgentRuntime) - cfg.Set("use_diskv2_check", false, configmodel.SourceAgentRuntime) - - diskFactory := diskv2.Factory() - diskCheckFunc, ok := diskFactory.Get() - require.True(t, ok) - diskCheck := diskCheckFunc() - - mock := mocksender.NewMockSender(diskCheck.ID()) - err := diskCheck.Configure(mock.GetSenderManager(), integration.FakeConfigHash, nil, nil, "test") - require.ErrorIs(t, err, check.ErrSkipCheckInstance) -} - func TestDiskCheckNonDefaultFlavor(t *testing.T) { for _, fl := range []string{flavor.IotAgent, flavor.ClusterAgent} { t.Run(fl, func(t *testing.T) { diff --git a/pkg/config/setup/config.go b/pkg/config/setup/config.go index ad127ae9e4cd52..8faaf3a12798dc 100644 --- a/pkg/config/setup/config.go +++ b/pkg/config/setup/config.go @@ -341,7 +341,7 @@ func InitConfig(config pkgconfigmodel.Setup) { config.BindEnvAndSetDefault("use_diskv2_check", true) config.BindEnvAndSetDefault("disk_check.use_core_loader", true) - // the darwin network and check has not been ported from python + // the darwin and bsd network check has not been ported from python if runtime.GOOS == "linux" || runtime.GOOS == "windows" { // If true, then new version of network v2 check will be used. // Otherwise, the python version of network check will be used.