Skip to content

Commit fb9f7a5

Browse files
AliDatadogtbavelier
andcommitted
Log warning only if useStandaloneImage is true
Co-authored-by: Timothée Bavelier <[email protected]>
1 parent 78a8a7c commit fb9f7a5

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

internal/controller/datadogagent/feature/otelcollector/feature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (o *otelCollectorFeature) Configure(dda metav1.Object, ddaSpec *v2alpha1.Da
9494
supportedVersion := utils.IsAboveMinVersion(agentVersion, "7.67.0-0")
9595
if !supportedVersion {
9696
// For unsupported versions, force UseStandaloneImage=false and log warning
97-
if apiutils.BoolValue(ddaSpec.Features.OtelCollector.Enabled) {
97+
if apiutils.BoolValue(ddaSpec.Features.OtelCollector.Enabled) && apiutils.BoolValue(ddaSpec.Features.OtelCollector.UseStandaloneImage) {
9898
o.logger.Info("UseStandaloneImage feature requires agent version 7.67.0 or higher",
9999
"current_version", agentVersion, "switching_to_full_image", true)
100100
}

internal/controller/datadogagent/feature/otelcollector/feature_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,55 @@ func Test_otelCollectorFeature_VersionCheck(t *testing.T) {
743743
},
744744
},
745745
},
746+
{
747+
Name: "UseStandaloneImage with full image in Name field 7.67.0+",
748+
DDA: testutils.NewDatadogAgentBuilder().
749+
WithOTelCollectorEnabled(true).
750+
WithOTelCollectorUseStandaloneImage(true).
751+
WithComponentOverride(v2alpha1.NodeAgentComponentName, v2alpha1.DatadogAgentComponentOverride{
752+
Image: &v2alpha1.AgentImageConfig{
753+
Name: "gcr.io/datadoghq/agent:7.67.0-full",
754+
},
755+
}).
756+
Build(),
757+
WantConfigure: true,
758+
Agent: &test.ComponentTest{
759+
CreateFunc: func(t testing.TB) (feature.PodTemplateManagers, string) {
760+
newPTS := corev1.PodTemplateSpec{
761+
Spec: corev1.PodSpec{
762+
Containers: []corev1.Container{
763+
{
764+
Name: string(apicommon.CoreAgentContainerName),
765+
Image: "gcr.io/datadoghq/agent:7.67.0-full",
766+
Command: []string{"agent", "run"},
767+
},
768+
{
769+
Name: string(apicommon.OtelAgent),
770+
Image: "gcr.io/datadoghq/agent:7.67.0-full", // This will be changed to ddot-collector
771+
Command: []string{"otel-agent"},
772+
},
773+
},
774+
},
775+
}
776+
return fake.NewPodTemplateManagers(t, newPTS), kubernetes.DefaultProvider
777+
},
778+
WantFunc: func(t testing.TB, mgrInterface feature.PodTemplateManagers) {
779+
mgr := mgrInterface.(*fake.PodTemplateManagers)
780+
// Version 7.67.0 is >= 7.67.0, so UseStandaloneImage should be enabled
781+
// When full image is provided in Name field, it should be used as-is for non-OTel containers
782+
// and converted to ddot-collector for OTel Agent
783+
for _, container := range mgr.PodTemplateSpec().Spec.Containers {
784+
if container.Name == string(apicommon.OtelAgent) {
785+
// OTel Agent should use ddot-collector image derived from the full image name
786+
assert.Equal(t, "gcr.io/datadoghq/ddot-collector:7.67.0", container.Image)
787+
} else {
788+
// Other containers should use the full image as provided
789+
assert.Equal(t, "gcr.io/datadoghq/agent:7.67.0-full", container.Image)
790+
}
791+
}
792+
},
793+
},
794+
},
746795
}
747796

748797
tests.Run(t, buildOtelCollectorFeature)

0 commit comments

Comments
 (0)