datadog-operator
datadog-operator copied to clipboard
[profiles] Improve DAP name length error
What does this PR do?
If a profile name is too long, older versions of the operator would run into an error attempting to label the node, leading to this error:
{"level":"ERROR","ts":"2024-05-15T21:05:59Z","msg":"Reconciler error","controller":"datadogagent","controllerGroup":"datadoghq.com","controllerKind":"DatadogAgent","datadogAgent":{"name":"datadog","namespace":"default"},"namespace":"default","name":"datadog","reconcileID":"aaeaa6dd-0e90-41fd-9094-e0b7931919a5","error":"Node \"kind-worker\" is invalid: metadata.labels: Invalid value: \"default-abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\": must be no more than 63 characters"}
It can be unexpected that the operator would complain about node labels when applying a profile. Instead, we now invalidate the profile and output an error message that clarifies that the profile name is the issue.
{"level":"ERROR","ts":"2024-06-27T17:20:12Z","logger":"controllers.DatadogAgent","msg":"datadogagentprofile","datadogagent":{"name":"datadog","namespace":"default"},"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz":"datadogagentprofile_namespace","error":"Profile name must be no more than 63 characters"}
{"level":"ERROR","ts":"2024-06-27T17:20:12Z","logger":"controllers.DatadogAgent","msg":"profile cannot be applied","datadogagent":{"name":"datadog","namespace":"default"},"datadogagentprofile":"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz","datadogagentprofile_namespace":"default","error":"Profile name must be no more than 63 characters"}
Motivation
https://datadoghq.atlassian.net/browse/CECO-1187
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
Write there any instructions and details you may have to test your PR.
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-qalabel
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 55.01%. Comparing base (
a3ce2ae) to head (89732b2).
Additional details and impacted files
@@ Coverage Diff @@
## main #1254 +/- ##
==========================================
+ Coverage 54.98% 55.01% +0.02%
==========================================
Files 243 243
Lines 27986 28002 +16
==========================================
+ Hits 15388 15404 +16
Misses 11729 11729
Partials 869 869
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 55.01% <100.00%> (+0.02%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files | Coverage Δ | |
|---|---|---|
| pkg/agentprofile/agent_profile.go | 63.17% <100.00%> (+2.43%) |
:arrow_up: |
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update a3ce2ae...89732b2. Read the comment docs.