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

[CECO-1240] Rename profile label key #1230

Merged
merged 3 commits into from
Jul 10, 2024
Merged

[CECO-1240] Rename profile label key #1230

merged 3 commits into from
Jul 10, 2024

Conversation

khewonc
Copy link
Contributor

@khewonc khewonc commented Jun 10, 2024

What does this PR do?

  • Renames the profile label key from agent.datadoghq.com/profile to agent.datadoghq.com/datadogagentprofile
  • Uses the dap name only as the label value instead of <namespace>-<name>, e.g. agent.datadoghq.com/datadogagentprofile:dap-test instead of agent.datadoghq.com/profile:default-dap-test
  • Removes old profile label from nodes, daemonsets, and pods
  • Uses datadogagentprofile and datadogagentprofile_namespace instead of name and namespace in profile-specific logs so they are more useful in the logs ui

Motivation

What inspired you to submit this pull request?

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: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

  1. Test the migration from operator <1.8.0 to 1.8.0+ to test the migration from old profile label to new profile label
    a. Spin up <1.8.0 operator version with profiles enabled: helm install operator --set image.tag="1.6.0" --set datadogAgentProfile.enabled=true datadog/datadog-operator
    b. Deploy DDA and DAP
    c. Check that the agent pod, ds, ds pod template spec, and node have the old label key and value agent.datadoghq.com/profile:<profile-ns>-<profile-name> and that the nodeaffinity for the default daemonset (ds that doesn't have the name xxx-with-profile-<profile-ns>-<profile-name>) has an expression for the agent.datadoghq.com/profile key
    d. Upgrade the operator to 1.8.0+
    e. Check that the agent pod, ds, ds pod template spec, and node have the new label key and value agent.datadoghq.com/datadogagentprofile:<profile-name> and that the nodeaffinity for the default daemonset has an expression for the agent.datadoghq.com/datadogagentprofile key
  2. Test that the removal of profiles removes the profile label on nodes
    a. Delete the profile
    b. Check that the agent pods, ds, and nodes don't have any profile label. The default daemonset should still have a nodeaffinity expression for the agent.datadoghq.com/datadogagentprofile key

Example label and nodeaffinity expression (for <1.8.0):

# label
    agent.datadoghq.com/profile: default-dap-test
# nodeaffinity expression
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: agent.datadoghq.com/profile
                operator: DoesNotExist

Example label and nodeaffinity expression (for 1.8.0+):

# label
    agent.datadoghq.com/datadogagentprofile: dap-test
# nodeaffinity expression
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: agent.datadoghq.com/datadogagentprofile
                operator: DoesNotExist
  1. Create an invalid profile (remove the profileAffinity from the profile) and check that the log uses datadogagentprofile and datadogagentprofile_namespace instead of name and namespace
{"level":"ERROR","ts":"2024-06-13T16:08:28Z","logger":"controllers.DatadogAgent","msg":"profile spec is invalid, skipping","datadogagent":"default/datadog","datadogagentprofile":"invalid-dap","datadogagentprofile_namespace":"default","error":"profileAffinity must be defined"}
{"level":"ERROR","ts":"2024-06-13T16:08:28Z","logger":"controllers.DatadogAgent","msg":"profile cannot be applied","datadogagent":"default/datadog","datadogagentprofile":"invalid-dap","datadogagentprofile_namespace":"default","error":"profileAffinity must be defined"}

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 Jun 10, 2024
@khewonc khewonc added this to the v1.8.0 milestone Jun 10, 2024
@khewonc khewonc requested review from a team as code owners June 10, 2024 20:13
@khewonc khewonc marked this pull request as draft June 10, 2024 20:16
@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2024

Codecov Report

Attention: Patch coverage is 69.23077% with 8 lines in your changes missing coverage. Please review.

Project coverage is 55.33%. Comparing base (ff60347) to head (b5feb95).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1230   +/-   ##
=======================================
  Coverage   55.32%   55.33%           
=======================================
  Files         241      241           
  Lines       27889    27889           
=======================================
+ Hits        15430    15432    +2     
+ Misses      11587    11586    -1     
+ Partials      872      871    -1     
Flag Coverage Δ
unittests 55.33% <69.23%> (+<0.01%) ⬆️

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

Files Coverage Δ
...ontrollers/datadogagent/controller_reconcile_v2.go 53.91% <100.00%> (ø)
controllers/datadogagent/finalizer.go 63.33% <88.88%> (+2.64%) ⬆️
...rollers/datadogagent/controller_reconcile_agent.go 50.42% <77.77%> (+0.28%) ⬆️
pkg/agentprofile/agent_profile.go 60.74% <50.00%> (-0.33%) ⬇️
...ers/datadogagent/controller_reconcile_v2_common.go 27.46% <0.00%> (-0.30%) ⬇️

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 ff60347...b5feb95. Read the comment docs.

@khewonc khewonc marked this pull request as ready for review June 13, 2024 15:28
@khewonc khewonc merged commit a3ce2ae into main Jul 10, 2024
19 checks passed
@khewonc khewonc deleted the khewonc/dap-renaming branch July 10, 2024 18:07
khewonc added a commit that referenced this pull request Jul 24, 2024
mftoure pushed a commit that referenced this pull request Oct 3, 2024
* Rename profile label key

* Remove old profile label

* Review suggestions
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