datadog-operator
datadog-operator copied to clipboard
[CECO-1240] Rename profile label key
What does this PR do?
- Renames the profile label key from
agent.datadoghq.com/profile
toagent.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 ofagent.datadoghq.com/profile:default-dap-test
- Removes old profile label from nodes, daemonsets, and pods
- Uses
datadogagentprofile
anddatadogagentprofile_namespace
instead ofname
andnamespace
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
- 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 valueagent.datadoghq.com/profile:<profile-ns>-<profile-name>
and that the nodeaffinity for the default daemonset (ds that doesn't have the namexxx-with-profile-<profile-ns>-<profile-name>
) has an expression for theagent.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 valueagent.datadoghq.com/datadogagentprofile:<profile-name>
and that the nodeaffinity for the default daemonset has an expression for theagent.datadoghq.com/datadogagentprofile
key - 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
- Create an invalid profile (remove the profileAffinity from the profile) and check that the log uses
datadogagentprofile
anddatadogagentprofile_namespace
instead ofname
andnamespace
{"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
- [x] PR has at least one valid label:
bug
,enhancement
,refactoring
,documentation
,tooling
, and/ordependencies
- [x] PR has a milestone or the
qa/skip-qa
label