From fd197585b379df27e8fe362407eddeb46b48be47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Bavelier?= Date: Wed, 8 Apr 2026 15:22:31 +0200 Subject: [PATCH] Do not use CRD to setup sd --- api/datadoghq/v2alpha1/datadogagent_types.go | 8 -- .../v2alpha1/zz_generated.deepcopy.go | 5 -- .../datadoghq.com_datadogagentinternals.yaml | 22 +----- ...hq.com_datadogagentinternals_v1alpha1.json | 12 +-- .../datadoghq.com_datadogagentprofiles.yaml | 11 +-- ...ghq.com_datadogagentprofiles_v1alpha1.json | 6 +- .../bases/v1/datadoghq.com_datadogagents.yaml | 22 +----- .../datadoghq.com_datadogagents_v2alpha1.json | 12 +-- docs/configuration.v2alpha1.md | 3 +- docs/configuration_public.md | 5 +- .../defaults/datadogagent_default.go | 11 +-- .../defaults/datadogagent_default_test.go | 78 ++++--------------- .../feature/servicediscovery/feature.go | 25 ++---- .../feature/servicediscovery/feature_test.go | 40 ++++------ 14 files changed, 53 insertions(+), 207 deletions(-) diff --git a/api/datadoghq/v2alpha1/datadogagent_types.go b/api/datadoghq/v2alpha1/datadogagent_types.go index 72c68a6454..09e6fbf163 100644 --- a/api/datadoghq/v2alpha1/datadogagent_types.go +++ b/api/datadoghq/v2alpha1/datadogagent_types.go @@ -643,17 +643,9 @@ type USMFeatureConfig struct { // ServiceDiscoveryFeatureConfig configures the service discovery check feature. type ServiceDiscoveryFeatureConfig struct { // Enables the service discovery check. - // Default: false // +optional Enabled *bool `json:"enabled,omitempty"` - // Indicates that the operator enabled this feature automatically rather than in response to an - // explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls - // back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on - // older agent images. This field is managed by the operator and must not be set by users. - // +optional - EnabledByDefault *bool `json:"enabledByDefault,omitempty"` - // DEPRECATED: NetworkStats is no longer configurable and will be ignored. Scheduled for removal in v1.28. // +deprecated // +optional diff --git a/api/datadoghq/v2alpha1/zz_generated.deepcopy.go b/api/datadoghq/v2alpha1/zz_generated.deepcopy.go index 0962f85f11..4733c0d92d 100644 --- a/api/datadoghq/v2alpha1/zz_generated.deepcopy.go +++ b/api/datadoghq/v2alpha1/zz_generated.deepcopy.go @@ -3453,11 +3453,6 @@ func (in *ServiceDiscoveryFeatureConfig) DeepCopyInto(out *ServiceDiscoveryFeatu *out = new(bool) **out = **in } - if in.EnabledByDefault != nil { - in, out := &in.EnabledByDefault, &out.EnabledByDefault - *out = new(bool) - **out = **in - } if in.NetworkStats != nil { in, out := &in.NetworkStats, &out.NetworkStats *out = new(ServiceDiscoveryNetworkStatsConfig) diff --git a/config/crd/bases/v1/datadoghq.com_datadogagentinternals.yaml b/config/crd/bases/v1/datadoghq.com_datadogagentinternals.yaml index c650cb9094..22f8cd9c36 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagentinternals.yaml +++ b/config/crd/bases/v1/datadoghq.com_datadogagentinternals.yaml @@ -2484,16 +2484,7 @@ spec: description: ServiceDiscovery properties: enabled: - description: |- - Enables the service discovery check. - Default: false - type: boolean - enabledByDefault: - description: |- - Indicates that the operator enabled this feature automatically rather than in response to an - explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls - back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on - older agent images. This field is managed by the operator and must not be set by users. + description: Enables the service discovery check. type: boolean networkStats: description: 'DEPRECATED: NetworkStats is no longer configurable and will be ignored. Scheduled for removal in v1.28.' @@ -10908,16 +10899,7 @@ spec: description: ServiceDiscovery properties: enabled: - description: |- - Enables the service discovery check. - Default: false - type: boolean - enabledByDefault: - description: |- - Indicates that the operator enabled this feature automatically rather than in response to an - explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls - back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on - older agent images. This field is managed by the operator and must not be set by users. + description: Enables the service discovery check. type: boolean networkStats: description: 'DEPRECATED: NetworkStats is no longer configurable and will be ignored. Scheduled for removal in v1.28.' diff --git a/config/crd/bases/v1/datadoghq.com_datadogagentinternals_v1alpha1.json b/config/crd/bases/v1/datadoghq.com_datadogagentinternals_v1alpha1.json index ca71c4e050..3648fa859a 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagentinternals_v1alpha1.json +++ b/config/crd/bases/v1/datadoghq.com_datadogagentinternals_v1alpha1.json @@ -2585,11 +2585,7 @@ "description": "ServiceDiscovery", "properties": { "enabled": { - "description": "Enables the service discovery check.\nDefault: false", - "type": "boolean" - }, - "enabledByDefault": { - "description": "Indicates that the operator enabled this feature automatically rather than in response to an\nexplicit user setting. When true, if `system-probe-lite` is unavailable, the container falls\nback to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on\nolder agent images. This field is managed by the operator and must not be set by users.", + "description": "Enables the service discovery check.", "type": "boolean" }, "networkStats": { @@ -10743,11 +10739,7 @@ "description": "ServiceDiscovery", "properties": { "enabled": { - "description": "Enables the service discovery check.\nDefault: false", - "type": "boolean" - }, - "enabledByDefault": { - "description": "Indicates that the operator enabled this feature automatically rather than in response to an\nexplicit user setting. When true, if `system-probe-lite` is unavailable, the container falls\nback to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on\nolder agent images. This field is managed by the operator and must not be set by users.", + "description": "Enables the service discovery check.", "type": "boolean" }, "networkStats": { diff --git a/config/crd/bases/v1/datadoghq.com_datadogagentprofiles.yaml b/config/crd/bases/v1/datadoghq.com_datadogagentprofiles.yaml index ba0ed09811..5df978acff 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagentprofiles.yaml +++ b/config/crd/bases/v1/datadoghq.com_datadogagentprofiles.yaml @@ -2484,16 +2484,7 @@ spec: description: ServiceDiscovery properties: enabled: - description: |- - Enables the service discovery check. - Default: false - type: boolean - enabledByDefault: - description: |- - Indicates that the operator enabled this feature automatically rather than in response to an - explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls - back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on - older agent images. This field is managed by the operator and must not be set by users. + description: Enables the service discovery check. type: boolean networkStats: description: 'DEPRECATED: NetworkStats is no longer configurable and will be ignored. Scheduled for removal in v1.28.' diff --git a/config/crd/bases/v1/datadoghq.com_datadogagentprofiles_v1alpha1.json b/config/crd/bases/v1/datadoghq.com_datadogagentprofiles_v1alpha1.json index b4ae8fa9e8..053e92d089 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagentprofiles_v1alpha1.json +++ b/config/crd/bases/v1/datadoghq.com_datadogagentprofiles_v1alpha1.json @@ -2589,11 +2589,7 @@ "description": "ServiceDiscovery", "properties": { "enabled": { - "description": "Enables the service discovery check.\nDefault: false", - "type": "boolean" - }, - "enabledByDefault": { - "description": "Indicates that the operator enabled this feature automatically rather than in response to an\nexplicit user setting. When true, if `system-probe-lite` is unavailable, the container falls\nback to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on\nolder agent images. This field is managed by the operator and must not be set by users.", + "description": "Enables the service discovery check.", "type": "boolean" }, "networkStats": { diff --git a/config/crd/bases/v1/datadoghq.com_datadogagents.yaml b/config/crd/bases/v1/datadoghq.com_datadogagents.yaml index 0cc1976a1c..4ebe115ce1 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagents.yaml +++ b/config/crd/bases/v1/datadoghq.com_datadogagents.yaml @@ -2484,16 +2484,7 @@ spec: description: ServiceDiscovery properties: enabled: - description: |- - Enables the service discovery check. - Default: false - type: boolean - enabledByDefault: - description: |- - Indicates that the operator enabled this feature automatically rather than in response to an - explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls - back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on - older agent images. This field is managed by the operator and must not be set by users. + description: Enables the service discovery check. type: boolean networkStats: description: 'DEPRECATED: NetworkStats is no longer configurable and will be ignored. Scheduled for removal in v1.28.' @@ -10958,16 +10949,7 @@ spec: description: ServiceDiscovery properties: enabled: - description: |- - Enables the service discovery check. - Default: false - type: boolean - enabledByDefault: - description: |- - Indicates that the operator enabled this feature automatically rather than in response to an - explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls - back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on - older agent images. This field is managed by the operator and must not be set by users. + description: Enables the service discovery check. type: boolean networkStats: description: 'DEPRECATED: NetworkStats is no longer configurable and will be ignored. Scheduled for removal in v1.28.' diff --git a/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json b/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json index ad91ec1663..f2c5d813b7 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json +++ b/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json @@ -2585,11 +2585,7 @@ "description": "ServiceDiscovery", "properties": { "enabled": { - "description": "Enables the service discovery check.\nDefault: false", - "type": "boolean" - }, - "enabledByDefault": { - "description": "Indicates that the operator enabled this feature automatically rather than in response to an\nexplicit user setting. When true, if `system-probe-lite` is unavailable, the container falls\nback to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on\nolder agent images. This field is managed by the operator and must not be set by users.", + "description": "Enables the service discovery check.", "type": "boolean" }, "networkStats": { @@ -10808,11 +10804,7 @@ "description": "ServiceDiscovery", "properties": { "enabled": { - "description": "Enables the service discovery check.\nDefault: false", - "type": "boolean" - }, - "enabledByDefault": { - "description": "Indicates that the operator enabled this feature automatically rather than in response to an\nexplicit user setting. When true, if `system-probe-lite` is unavailable, the container falls\nback to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on\nolder agent images. This field is managed by the operator and must not be set by users.", + "description": "Enables the service discovery check.", "type": "boolean" }, "networkStats": { diff --git a/docs/configuration.v2alpha1.md b/docs/configuration.v2alpha1.md index d3005524cb..b3663df1aa 100644 --- a/docs/configuration.v2alpha1.md +++ b/docs/configuration.v2alpha1.md @@ -199,8 +199,7 @@ spec: | features.sbom.enabled | Enable this option to activate SBOM collection. Default: false | | features.sbom.host.analyzers | To use for SBOM collection. | | features.sbom.host.enabled | Enable this option to activate SBOM collection. Default: false | -| features.serviceDiscovery.enabled | Enables the service discovery check. Default: false | -| features.serviceDiscovery.enabledByDefault | Indicates that the operator enabled this feature automatically rather than in response to an explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on older agent images. This field is managed by the operator and must not be set by users. | +| features.serviceDiscovery.enabled | Enables the service discovery check. | | features.serviceDiscovery.networkStats.enabled | DEPRECATED: this field is ignored. | | features.tcpQueueLength.enabled | Enables the TCP queue length eBPF-based check. Default: false | | features.usm.enabled | Enables Universal Service Monitoring. Default: false | diff --git a/docs/configuration_public.md b/docs/configuration_public.md index 3fd7f241c9..a0280b02ef 100644 --- a/docs/configuration_public.md +++ b/docs/configuration_public.md @@ -382,10 +382,7 @@ spec: : Enable this option to activate SBOM collection. Default: false `features.serviceDiscovery.enabled` -: Enables the service discovery check. Default: false - -`features.serviceDiscovery.enabledByDefault` -: Indicates that the operator enabled this feature automatically rather than in response to an explicit user setting. When true, if `system-probe-lite` is unavailable, the container falls back to `sleep infinity` rather than `system-probe`, to avoid unexpected resource usage on older agent images. This field is managed by the operator and must not be set by users. +: Enables the service discovery check. `features.serviceDiscovery.networkStats.enabled` : DEPRECATED: this field is ignored. diff --git a/internal/controller/datadogagent/defaults/datadogagent_default.go b/internal/controller/datadogagent/defaults/datadogagent_default.go index 24d807412c..21148dc309 100644 --- a/internal/controller/datadogagent/defaults/datadogagent_default.go +++ b/internal/controller/datadogagent/defaults/datadogagent_default.go @@ -41,9 +41,6 @@ const ( defaultGPUMonitoringEnabled bool = false - defaultServiceDiscoveryEnabled bool = false - defaultServiceDiscoveryEnabledByDefault bool = false - defaultAPMEnabled bool = true defaultAPMHostPortEnabled bool = false defaultAPMHostPort int32 = 8126 @@ -303,12 +300,8 @@ func defaultFeaturesConfig(ddaSpec *v2alpha1.DatadogAgentSpec) { if ddaSpec.Features.ServiceDiscovery == nil { ddaSpec.Features.ServiceDiscovery = &v2alpha1.ServiceDiscoveryFeatureConfig{} } - apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.ServiceDiscovery.EnabledByDefault, defaultServiceDiscoveryEnabledByDefault) - // Only default Enabled to false when not enabled-by-default, so that Enabled=nil remains - // distinguishable from Enabled=false (explicit user opt-out) when EnabledByDefault=true. - if !apiutils.BoolValue(ddaSpec.Features.ServiceDiscovery.EnabledByDefault) { - apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.ServiceDiscovery.Enabled, defaultServiceDiscoveryEnabled) - } + // Intentionally leave ServiceDiscovery.Enabled unset to preserve the distinction + // between an explicit opt-out (false) and future operator-driven default enablement (nil). // GPU monitoring feature if ddaSpec.Features.GPU == nil { diff --git a/internal/controller/datadogagent/defaults/datadogagent_default_test.go b/internal/controller/datadogagent/defaults/datadogagent_default_test.go index 46b945fdd3..14760fc7a4 100644 --- a/internal/controller/datadogagent/defaults/datadogagent_default_test.go +++ b/internal/controller/datadogagent/defaults/datadogagent_default_test.go @@ -211,10 +211,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -361,10 +358,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -461,10 +455,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -598,10 +589,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -760,10 +748,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -917,10 +902,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -1074,10 +1056,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -1240,10 +1219,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -1397,10 +1373,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -1557,10 +1530,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -1760,10 +1730,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -1886,10 +1853,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -2044,10 +2008,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -2225,10 +2186,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -2385,10 +2343,7 @@ func Test_defaultFeatures(t *testing.T) { EBPFCheck: &v2alpha1.EBPFCheckFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), - }, + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), }, @@ -2559,8 +2514,7 @@ func Test_defaultFeatures(t *testing.T) { Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled), }, ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - Enabled: apiutils.NewBoolPointer(valueTrue), - EnabledByDefault: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabledByDefault), + Enabled: apiutils.NewBoolPointer(valueTrue), }, GPU: &v2alpha1.GPUFeatureConfig{ Enabled: apiutils.NewBoolPointer(defaultGPUMonitoringEnabled), diff --git a/internal/controller/datadogagent/feature/servicediscovery/feature.go b/internal/controller/datadogagent/feature/servicediscovery/feature.go index 6227d2c1ad..e2c5d82e66 100644 --- a/internal/controller/datadogagent/feature/servicediscovery/feature.go +++ b/internal/controller/datadogagent/feature/servicediscovery/feature.go @@ -31,7 +31,6 @@ func buildFeature(*feature.Options) feature.Feature { } type serviceDiscoveryFeature struct { - userExplicitlyEnabled bool // features holds a pointer to the live DDA features struct so that ManageNodeAgent // can re-evaluate hasOtherSystemProbeFeatures after Remote Config state has been // merged by other features' Configure calls (e.g. USM merges RC state into the spec). @@ -51,12 +50,7 @@ func (f *serviceDiscoveryFeature) Configure(_ metav1.Object, ddaSpec *v2alpha1.D sd := ddaSpec.Features.ServiceDiscovery - // Explicit Enabled=false always disables the feature, even if EnabledByDefault=true. - if sd.Enabled != nil && !*sd.Enabled { - return reqComp - } - // Feature requires either an explicit opt-in or a default enablement. - if !apiutils.BoolValue(sd.Enabled) && !apiutils.BoolValue(sd.EnabledByDefault) { + if !apiutils.BoolValue(sd.Enabled) { return reqComp } @@ -66,22 +60,15 @@ func (f *serviceDiscoveryFeature) Configure(_ metav1.Object, ddaSpec *v2alpha1.D } f.features = ddaSpec.Features - f.userExplicitlyEnabled = apiutils.BoolValue(sd.Enabled) return reqComp } // systemProbeLiteCommand returns the shell command for the system-probe container when -// system-probe-lite is preferred. If userOptedIn is true (user explicitly enabled discovery), -// system-probe is used as the fallback — the user has accepted the resource cost. -// Otherwise (enabled by default), the fallback is sleep infinity to avoid unexpectedly -// running system-probe on older agent images where the discovery feature may not be supported. -func systemProbeLiteCommand(socketPath string, userOptedIn bool) string { - fallback := "sleep infinity" - if userOptedIn { - fallback = "system-probe --config=/etc/datadog-agent/system-probe.yaml" - } - return fmt.Sprintf("system-probe-lite run --socket %s --log-level ${DD_LOG_LEVEL:-info} || %s", socketPath, fallback) +// system-probe-lite is preferred. If it is unavailable in the image, the container +// falls back to the regular system-probe binary. +func systemProbeLiteCommand(socketPath string) string { + return fmt.Sprintf("system-probe-lite run --socket %s --log-level ${DD_LOG_LEVEL:-info} || system-probe --config=/etc/datadog-agent/system-probe.yaml", socketPath) } // hasOtherSystemProbeFeatures returns true if any feature besides service discovery @@ -163,7 +150,7 @@ func (f *serviceDiscoveryFeature) ManageNodeAgent(managers feature.PodTemplateMa c := &managers.PodTemplateSpec().Spec.Containers[i] if c.Name == string(apicommon.SystemProbeContainerName) { c.Command = []string{"/bin/sh", "-c"} - c.Args = []string{systemProbeLiteCommand(common.DefaultSystemProbeSocketPath, f.userExplicitlyEnabled)} + c.Args = []string{systemProbeLiteCommand(common.DefaultSystemProbeSocketPath)} break } } diff --git a/internal/controller/datadogagent/feature/servicediscovery/feature_test.go b/internal/controller/datadogagent/feature/servicediscovery/feature_test.go index fae1bc70b5..b70e4cde1b 100644 --- a/internal/controller/datadogagent/feature/servicediscovery/feature_test.go +++ b/internal/controller/datadogagent/feature/servicediscovery/feature_test.go @@ -23,6 +23,13 @@ import ( ) func Test_serviceDiscoveryFeature_Configure(t *testing.T) { + ddaServiceDiscoveryUnset := v2alpha1.DatadogAgent{ + Spec: v2alpha1.DatadogAgentSpec{ + Features: &v2alpha1.DatadogFeatures{ + ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{}, + }, + }, + } ddaServiceDiscoveryDisabled := v2alpha1.DatadogAgent{ Spec: v2alpha1.DatadogAgentSpec{ Features: &v2alpha1.DatadogFeatures{ @@ -61,17 +68,12 @@ func Test_serviceDiscoveryFeature_Configure(t *testing.T) { }, } - ddaEnabledByDefault := v2alpha1.DatadogAgent{ - Spec: v2alpha1.DatadogAgentSpec{ - Features: &v2alpha1.DatadogFeatures{ - ServiceDiscovery: &v2alpha1.ServiceDiscoveryFeatureConfig{ - EnabledByDefault: apiutils.NewBoolPointer(true), - }, - }, - }, - } - tests := test.FeatureTestSuite{ + { + Name: "service discovery not enabled when unset", + DDA: &ddaServiceDiscoveryUnset, + WantConfigure: false, + }, { Name: "service discovery not enabled", DDA: ddaServiceDiscoveryDisabled.DeepCopy(), @@ -83,7 +85,7 @@ func Test_serviceDiscoveryFeature_Configure(t *testing.T) { WantConfigure: true, Agent: test.NewDefaultComponentTest(). WithCreateFunc(createFuncWithSystemProbeContainer()). - WithWantFunc(getWantFunc(true, true)), + WithWantFunc(getWantFunc(true)), }, { Name: "system-probe-lite not used when NPM also enabled", @@ -91,7 +93,7 @@ func Test_serviceDiscoveryFeature_Configure(t *testing.T) { WantConfigure: true, Agent: test.NewDefaultComponentTest(). WithCreateFunc(createFuncWithSystemProbeContainer()). - WithWantFunc(getWantFunc(false, true)), + WithWantFunc(getWantFunc(false)), }, { Name: "system-probe-lite not used when CWS also enabled", @@ -99,15 +101,7 @@ func Test_serviceDiscoveryFeature_Configure(t *testing.T) { WantConfigure: true, Agent: test.NewDefaultComponentTest(). WithCreateFunc(createFuncWithSystemProbeContainer()). - WithWantFunc(getWantFunc(false, true)), - }, - { - Name: "system-probe-lite enabled by default - no system-probe fallback", - DDA: &ddaEnabledByDefault, - WantConfigure: true, - Agent: test.NewDefaultComponentTest(). - WithCreateFunc(createFuncWithSystemProbeContainer()). - WithWantFunc(getWantFunc(true, false)), + WithWantFunc(getWantFunc(false)), }, } @@ -237,7 +231,7 @@ func createFuncWithSystemProbeContainer() func(testing.TB) (feature.PodTemplateM } } -func getWantFunc(useSPL bool, userOptedIn bool) func(t testing.TB, mgrInterface feature.PodTemplateManagers) { +func getWantFunc(useSPL bool) func(t testing.TB, mgrInterface feature.PodTemplateManagers) { return func(t testing.TB, mgrInterface feature.PodTemplateManagers) { mgr := mgrInterface.(*fake.PodTemplateManagers) @@ -346,7 +340,7 @@ func getWantFunc(useSPL bool, userOptedIn bool) func(t testing.TB, mgrInterface if c.Name == string(apicommon.SystemProbeContainerName) { if useSPL { assert.Equal(t, []string{"/bin/sh", "-c"}, c.Command, "System Probe command should be overridden for system-probe-lite") - assert.Equal(t, []string{systemProbeLiteCommand(common.DefaultSystemProbeSocketPath, userOptedIn)}, c.Args, "System Probe args mismatch") + assert.Equal(t, []string{systemProbeLiteCommand(common.DefaultSystemProbeSocketPath)}, c.Args, "System Probe args mismatch") } else { assert.Empty(t, c.Command, "System Probe command should not be overridden") assert.Empty(t, c.Args, "System Probe args should not be overridden")