Skip to content

Commit

Permalink
Remove support for otel annotation (#1624)
Browse files Browse the repository at this point in the history
This PR removes support for enabling otel-agent via annotations in favor of enabling otel agent vie otelCollector feature: #1559.

The annotation use has already been removed in staging: DataDog/k8s-datadog-agent-ops#4602.
  • Loading branch information
mackjmr authored Jan 14, 2025
1 parent 463ab54 commit 841842e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 174 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,6 @@ func (f *defaultFeature) Configure(dda *v2alpha1.DatadogAgent) feature.RequiredC

agentContainers := make([]apicommon.AgentContainerName, 0)

// If the OpenTelemetry Agent is enabled, add the OTel Agent to the list of required containers for the Agent
// feature.
//
// NOTE: This is a temporary solution until the OTel Agent is fully integrated into the Operator via a dedicated feature.
if dda.ObjectMeta.Annotations != nil && featureutils.HasOtelAgentAnnotation(dda) {
agentContainers = append(agentContainers, apicommon.OtelAgent)
}

// If Agent Data Plane is enabled, add the ADP container to the list of required containers for the Agent feature.
if f.adpEnabled {
agentContainers = append(agentContainers, apicommon.AgentDataPlaneContainerName)
Expand Down
73 changes: 3 additions & 70 deletions internal/controller/datadogagent/feature/test/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,57 +165,8 @@ func TestBuilder(t *testing.T) {
},
},
{
name: "Default DDA, default feature Option, otel-agent-enabled annotation true",
name: "Default DDA, otel collector feature enabled",
dda: testutils.NewDatadogAgentBuilder().
WithAnnotations(map[string]string{"agent.datadoghq.com/otel-agent-enabled": "true"}).
BuildWithDefaults(),
wantAgentContainer: map[common.AgentContainerName]bool{
common.UnprivilegedSingleAgentContainerName: false,
common.CoreAgentContainerName: true,
common.ProcessAgentContainerName: true,
common.TraceAgentContainerName: true,
common.SystemProbeContainerName: false,
common.SecurityAgentContainerName: false,
common.OtelAgent: true,
common.AgentDataPlaneContainerName: false,
},
},
{
name: "Default DDA, default feature Option, otel-agent-enabled annotation false",
dda: testutils.NewDatadogAgentBuilder().
WithAnnotations(map[string]string{"agent.datadoghq.com/otel-agent-enabled": "false"}).
BuildWithDefaults(),
wantAgentContainer: map[common.AgentContainerName]bool{
common.UnprivilegedSingleAgentContainerName: false,
common.CoreAgentContainerName: true,
common.ProcessAgentContainerName: true,
common.TraceAgentContainerName: true,
common.SystemProbeContainerName: false,
common.SecurityAgentContainerName: false,
common.OtelAgent: false,
common.AgentDataPlaneContainerName: false,
},
},
{
name: "Default DDA, no otel annotation, Operator option enabled",
dda: testutils.NewDatadogAgentBuilder().
WithAnnotations(map[string]string{"agent.datadoghq.com/otel-agent-enabled": "false"}).
BuildWithDefaults(),
wantAgentContainer: map[common.AgentContainerName]bool{
common.UnprivilegedSingleAgentContainerName: false,
common.CoreAgentContainerName: true,
common.ProcessAgentContainerName: true,
common.TraceAgentContainerName: true,
common.SystemProbeContainerName: false,
common.SecurityAgentContainerName: false,
common.OtelAgent: false,
common.AgentDataPlaneContainerName: false,
},
},
{
name: "Default DDA, otel annotation false, otel collector feature enabled",
dda: testutils.NewDatadogAgentBuilder().
WithAnnotations(map[string]string{"agent.datadoghq.com/otel-agent-enabled": "false"}).
WithOTelCollectorEnabled(true).
BuildWithDefaults(),
wantAgentContainer: map[common.AgentContainerName]bool{
Expand All @@ -230,9 +181,8 @@ func TestBuilder(t *testing.T) {
},
},
{
name: "Default DDA, otel annotation true, otel collector feature disabled",
name: "Default DDA, otel collector feature disabled",
dda: testutils.NewDatadogAgentBuilder().
WithAnnotations(map[string]string{"agent.datadoghq.com/otel-agent-enabled": "true"}).
WithOTelCollectorEnabled(false).
BuildWithDefaults(),
wantAgentContainer: map[common.AgentContainerName]bool{
Expand All @@ -242,24 +192,7 @@ func TestBuilder(t *testing.T) {
common.TraceAgentContainerName: true,
common.SystemProbeContainerName: false,
common.SecurityAgentContainerName: false,
common.OtelAgent: true,
common.AgentDataPlaneContainerName: false,
},
},
{
name: "Default DDA, otel annotation true, otel collector feature enabled",
dda: testutils.NewDatadogAgentBuilder().
WithAnnotations(map[string]string{"agent.datadoghq.com/otel-agent-enabled": "true"}).
WithOTelCollectorEnabled(true).
BuildWithDefaults(),
wantAgentContainer: map[common.AgentContainerName]bool{
common.UnprivilegedSingleAgentContainerName: false,
common.CoreAgentContainerName: true,
common.ProcessAgentContainerName: true,
common.TraceAgentContainerName: true,
common.SystemProbeContainerName: false,
common.SecurityAgentContainerName: false,
common.OtelAgent: true,
common.OtelAgent: false,
common.AgentDataPlaneContainerName: false,
},
},
Expand Down
7 changes: 0 additions & 7 deletions internal/controller/datadogagent/feature/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
)

const RunInCoreAgentMinVersion = "7.57.0-0"
const enableOtelAnnotation = "agent.datadoghq.com/otel-agent-enabled"
const enableAdpAnnotation = "agent.datadoghq.com/adp-enabled"

func agentSupportsRunInCoreAgent(dda *v2alpha1.DatadogAgent) bool {
Expand Down Expand Up @@ -57,12 +56,6 @@ func hasFeatureEnableAnnotation(dda *v2alpha1.DatadogAgent, annotation string) b
return false
}

// HasOtelAgentAnnotation returns true if the OpenTelemetry Agent is enabled via the dedicated
// `agent.datadoghq.com/otel-agent-enabled` annotation
func HasOtelAgentAnnotation(dda *v2alpha1.DatadogAgent) bool {
return hasFeatureEnableAnnotation(dda, enableOtelAnnotation)
}

// HasAgentDataPlaneAnnotation returns true if the Agent Data Plane is enabled via the dedicated `agent.datadoghq.com/adp-enabled` annotation
func HasAgentDataPlaneAnnotation(dda *v2alpha1.DatadogAgent) bool {
return hasFeatureEnableAnnotation(dda, enableAdpAnnotation)
Expand Down

0 comments on commit 841842e

Please sign in to comment.