Skip to content
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

[profiles] Override node agent env vars with profiles #1256

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

khewonc
Copy link
Contributor

@khewonc khewonc commented Jul 1, 2024

What does this PR do?

Adds the ability to override node agent env vars with profiles

Motivation

Internal request
https://datadoghq.atlassian.net/browse/CECO-1225

Additional Notes

Anything else we should know when reviewing?

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: n/a
  • Cluster Agent: n/a

Describe your test plan

  • Spin up the operator with profiles enabled
  • Deploy a DatadogAgent with an env var override for one of the agent containers. Example:
  override:
    nodeAgent:
      containers:
        agent:
          env:
            - name: TEST
              value: "foo"
  • Check that the override works. In the above example, the agent container should have env var TEST: foo
  • Apply a profile that:
    • overrides the DatadogAgent's env var
    • adds a new env var using value
    • adds a new env var using valueFrom
    override:
      nodeAgent:
        containers:
          agent:
            env:
            - name: TEST
              value: "test"
            - {name: TEST_VALUE_FROM, valueFrom: {fieldRef: {fieldPath: status.hostIP}}}
            - name: ANOTHER_VALUE_FROM
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP
            resources:
              limits:
                cpu: "0.25"
          trace-agent:
            env:
            - name: TRACE_TEST
              value: "trace_test"
  • Check for expected results. If using the above examples, we'd expect the agent container for a profile-created node agent had env var TEST:test but the node agent container that wasn't created by the profile still had TEST:foo. The profile-created node agent should also have both TEST_VALUE_FROM and ANOTHER_VALUE_FROM set to the node's status.hostIP. The trace agent should have TRACE_TEST:trace_test and the process agent shouldn't have any env var overrides
# profile-created node agent
# agent container
      TEST:                                                  test
      TEST_VALUE_FROM:                                        (v1:status.hostIP)
      ANOTHER_VALUE_FROM:                                     (v1:status.hostIP)
# trace agent container
      TRACE_TEST:                                trace_test

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label

@khewonc khewonc added the enhancement New feature or request label Jul 1, 2024
@khewonc khewonc added this to the v1.8.0 milestone Jul 1, 2024
@khewonc khewonc requested review from a team as code owners July 1, 2024 21:07
@codecov-commenter
Copy link

codecov-commenter commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.01%. Comparing base (979aa8e) to head (4519c95).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1256   +/-   ##
=======================================
  Coverage   55.01%   55.01%           
=======================================
  Files         243      243           
  Lines       28002    28003    +1     
=======================================
+ Hits        15404    15405    +1     
  Misses      11729    11729           
  Partials      869      869           
Flag Coverage Δ
unittests 55.01% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...is/datadoghq/v1alpha1/datadogagentprofile_types.go 100.00% <ø> (ø)
pkg/agentprofile/agent_profile.go 63.32% <100.00%> (+0.14%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 979aa8e...4519c95. Read the comment docs.

@khewonc khewonc merged commit f08182d into main Jul 10, 2024
19 checks passed
@khewonc khewonc deleted the khewonc/dap-env-var-override branch July 10, 2024 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants