Skip to content

Commit

Permalink
Only set INSTALLATION environment variables when doing injection (Dat…
Browse files Browse the repository at this point in the history
…aDog#31503)

Co-authored-by: Rosa Trieu <[email protected]>
  • Loading branch information
stanistan and rtrieu authored Dec 9, 2024
1 parent 0b3f726 commit c5069b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (w *Webhook) inject(pod *corev1.Pod, ns string, _ dynamic.Interface) (bool,
if pod.Namespace == "" {
pod.Namespace = ns
}
injectApmTelemetryConfig(pod)

if !w.isPodEligible(pod) {
return false, nil
Expand Down Expand Up @@ -371,6 +370,9 @@ func (s libInfoSource) mutatePod(pod *corev1.Pod) error {
Name: instrumentationInstallTypeEnvVarName,
Value: s.injectionType(),
})

injectApmTelemetryConfig(pod)

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2307,16 +2307,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
"admission.datadoghq.com/enabled": "false",
},
}.Create(),
expectedEnvs: []corev1.EnvVar{
{
Name: "DD_INSTRUMENTATION_INSTALL_TIME",
Value: installTime,
},
{
Name: "DD_INSTRUMENTATION_INSTALL_ID",
Value: uuid,
},
},
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand Down Expand Up @@ -2415,16 +2406,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
ParentKind: "replicaset",
ParentName: "test-deployment-123",
}.Create(),
expectedEnvs: []corev1.EnvVar{
{
Name: "DD_INSTRUMENTATION_INSTALL_TIME",
Value: installTime,
},
{
Name: "DD_INSTRUMENTATION_INSTALL_ID",
Value: uuid,
},
},
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand Down Expand Up @@ -2495,16 +2477,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
ParentKind: "replicaset",
ParentName: "test-deployment-123",
}.Create(),
expectedEnvs: []corev1.EnvVar{
{
Name: "DD_INSTRUMENTATION_INSTALL_TIME",
Value: installTime,
},
{
Name: "DD_INSTRUMENTATION_INSTALL_ID",
Value: uuid,
},
},
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand All @@ -2517,16 +2490,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
ParentKind: "replicaset",
ParentName: "test-deployment-123",
}.Create(),
expectedEnvs: []corev1.EnvVar{
{
Name: "DD_INSTRUMENTATION_INSTALL_TIME",
Value: installTime,
},
{
Name: "DD_INSTRUMENTATION_INSTALL_ID",
Value: uuid,
},
},
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
The auto-instrumentation webhook no longer injects the default environment
variables when disabled.

0 comments on commit c5069b5

Please sign in to comment.