diff --git a/pkg/collector/corechecks/system/disk/diskv2/disk_test.go b/pkg/collector/corechecks/system/disk/diskv2/disk_test.go index 79f195a7684ac1..b802a2973fa4cd 100644 --- a/pkg/collector/corechecks/system/disk/diskv2/disk_test.go +++ b/pkg/collector/corechecks/system/disk/diskv2/disk_test.go @@ -1355,22 +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) - - 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/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/pkg/config/setup/config.go b/pkg/config/setup/config.go index c3cd031ebeb291..f39f41874c9973 100644 --- a/pkg/config/setup/config.go +++ b/pkg/config/setup/config.go @@ -327,20 +327,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) - - // 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) + // Otherwise, the python version of disk check will be used. + config.BindEnvAndSetDefault("use_diskv2_check", true) + config.BindEnvAndSetDefault("disk_check.use_core_loader", true) + + // 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. + 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 // dependent; default should remain false on Windows to maintain backward 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. + 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..53631c4921915b 100644 --- a/test/new-e2e/tests/agent-platform/common/agent_behaviour.go +++ b/test/new-e2e/tests/agent-platform/common/agent_behaviour.go @@ -231,6 +231,8 @@ func SetAgentPythonMajorVersion(t *testing.T, client *TestClient, majorVersion s configFilePath := client.Helper.GetConfigFolder() + client.Helper.GetConfigFileName() err := client.SetConfig(configFilePath, "python_version", majorVersion) 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")