datadog-operator icon indicating copy to clipboard operation
datadog-operator copied to clipboard

[DatadogAgent][Flare] Additional environment variables and RBAC to permit user manifests retrieval

Open tbavelier opened this issue 1 year ago • 1 comments

What does this PR do?

  • Adds 3 env vars to the cluster Agent:
    • AGENT_DAEMONSET: name of the node Agent ds
    • CLUSTER_AGENT_DEPLOYMENT: name of the DCA deployment
    • DATADOG_AGENT_CR_NAME: name of the DatadogAgent custom resource
  • Adds RBAC allowing the DCA to get the DatadogAgent custom resource from its namespace

Motivation

Similar to https://github.com/DataDog/helm-charts/pull/965, we need to inject a few variables/give some permissions to be able to collect the Agent deployment files while creating a flare to help with troubleshooting.

Additional Notes

The flare feature depending on these variables is available at: https://github.com/DataDog/datadog-agent/pull/30372

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

  • Deploy the operator
  • Deploy a DatadogAgent with cluster Agent enabled (default):
apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: foo
  • Assert on DCA:
    • AGENT_DAEMONSET: foo-agent, value of kubectl get ds
    • CLUSTER_AGENT_DEPLOYMENT: foo-cluster-agent, value of kubectl get deploy
    • DATADOG_AGENT_CR_NAME: foo, value of kubectl get dd
  • Add overrides:
apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: foo
override:
  nodeAgent:
    name: "x"
  clusterAgent:
    name: "y"
  • Assert on DCA:
    • AGENT_DAEMONSET: x, value of kubectl get ds
    • CLUSTER_AGENT_DEPLOYMENT: y, value of kubectl get deploy
    • DATADOG_AGENT_CR_NAME: foo, value of kubectl get dd

Checklist

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

tbavelier avatar Oct 22 '24 09:10 tbavelier

Codecov Report

:x: Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 48.69%. Comparing base (7c7d028) to head (efec96e). :warning: Report is 468 commits behind head on main.

Files with missing lines Patch % Lines
...troller/datadogagent/feature/enabledefault/rbac.go 0.00% 8 Missing :warning:
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1477      +/-   ##
==========================================
+ Coverage   48.64%   48.69%   +0.04%     
==========================================
  Files         224      225       +1     
  Lines       19869    19903      +34     
==========================================
+ Hits         9666     9692      +26     
- Misses       9694     9702       +8     
  Partials      509      509              
Flag Coverage Δ
unittests 48.69% <76.47%> (+0.04%) :arrow_up:

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

Files with missing lines Coverage Δ
...ller/datadogagent/feature/enabledefault/feature.go 37.36% <100.00%> (+2.79%) :arrow_up:
...roller/datadogagent/feature/enabledefault/utils.go 100.00% <100.00%> (ø)
...troller/datadogagent/feature/enabledefault/rbac.go 0.00% <0.00%> (ø)

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 7c7d028...efec96e. Read the comment docs.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Oct 22 '24 09:10 codecov-commenter