Skip to content

[BUG] Limit for autoinstrumentation init container calculated wrong #35170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
florianmutter opened this issue Mar 17, 2025 · 1 comment · Fixed by #35588
Open

[BUG] Limit for autoinstrumentation init container calculated wrong #35170

florianmutter opened this issue Mar 17, 2025 · 1 comment · Fixed by #35588

Comments

@florianmutter
Copy link

florianmutter commented Mar 17, 2025

Agent Environment

Agent 7.63.3 - Commit: eab078f2e7 - Serialization version: v5.0.141 - Go version: go1.23.5

Describe what happened:
Datadog webhook adds init containers with invalid resource spec. CPU limit can be smaller than request which is not allowed. This happens if there are multiple container in a pod where the sum all limits is smaller than the sum of all requests (e.g. because on container does not have a limit at all).

Describe what you expected:
Datadog Admission controller does not create invalid spec.

Steps to reproduce the issue:
Create a pod with two containers like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo
spec:
  template:
    spec:
      containers:
        - name: container1
          resources:
            limits:
              cpu: 1000m
              memory: 512Mi
            requests:
              cpu: 1000m
              memory: 512Mi
        - name: container2
          resources:
            limits:
              memory: 128Mi
            requests:
              cpu: 50m
              memory: 128Mi

Additional environment details (Operating System, Cloud provider, etc):
GKE.

The code that does this calculation wrong is probably here: https://github.com/DataDog/datadog-agent/blob/main/pkg/clusteragent/admission/mutate/autoinstrumentation/auto_instrumentation.go#L288

Seems to have been introduced with #30266

@florianmutter
Copy link
Author

Workaround is to add something like

env:
  - name: DD_ADMISSION_CONTROLLER_AUTO_INSTRUMENTATION_INIT_RESOURCES_CPU
    value: 100m
  - name: DD_ADMISSION_CONTROLLER_AUTO_INSTRUMENTATION_INIT_RESOURCES_MEMORY
    value: 100Mi

for the cluster agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants