Skip to content

Add cache namespace options for DatadogCSIDriver controller#2934

Merged
tbavelier merged 2 commits into
mainfrom
tbavelier/add-cache-datadogcsidriver
Apr 27, 2026
Merged

Add cache namespace options for DatadogCSIDriver controller#2934
tbavelier merged 2 commits into
mainfrom
tbavelier/add-cache-datadogcsidriver

Conversation

@tbavelier

@tbavelier tbavelier commented Apr 24, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Adds cache namespace configuration for the DatadogCSIDriver controller, consistent with all other controllers.

Introduces DD_CSIDRIVER_WATCH_NAMESPACE env var (falls back to WATCH_NAMESPACE), wires DatadogCSIDriverEnabled into config.CacheOptions(), and adds test coverage.

Motivation

The DatadogCSIDriver controller was the only controller missing its own cache namespace entry. Without it, the controller fell back to DefaultNamespaces (driven by DD_AGENT_WATCH_NAMESPACE/WATCH_NAMESPACE) instead of having its own DD_CSIDRIVER_WATCH_NAMESPACE override.

Additionally, DatadogCSIDriver is unique among controllers in that it creates and reconciles a native k8s DaemonSet, which must also be accessible from the cache. If the CSIDriver is deployed in a different namespace than the agent (e.g. DD_CSIDRIVER_WATCH_NAMESPACE=default, DD_AGENT_WATCH_NAMESPACE=system), the DaemonSet falls outside DefaultNamespaces and causes:

getting DaemonSet: unable to get: default/datadog-csi-driver-node-server because of unknown namespace for the cache

The fix explicitly adds DaemonSet to ByObject with the union of agent and CSIDriver namespaces. Using DefaultNamespaces instead would over-cache all other GVKs (Secrets, ConfigMaps, etc.) in the CSIDriver namespace unnecessarily.

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
  • All commits are signed (see: signing commits)

@tbavelier
tbavelier requested a review from a team April 24, 2026 14:37
@tbavelier tbavelier added this to the v1.26.0 milestone Apr 24, 2026
@tbavelier tbavelier added the enhancement New feature or request label Apr 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c03249ea32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/config/config.go
@codecov-commenter

codecov-commenter commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 40.71%. Comparing base (039572f) to head (2c74ee7).

Files with missing lines Patch % Lines
cmd/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2934      +/-   ##
==========================================
+ Coverage   40.69%   40.71%   +0.01%     
==========================================
  Files         321      321              
  Lines       28413    28423      +10     
==========================================
+ Hits        11563    11572       +9     
- Misses      16015    16016       +1     
  Partials      835      835              
Flag Coverage Δ
unittests 40.71% <90.00%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
pkg/config/config.go 66.66% <100.00%> (+3.44%) ⬆️
cmd/main.go 6.64% <0.00%> (-0.02%) ⬇️

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 039572f...2c74ee7. Read the comment docs.

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

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Apr 24, 2026

Copy link
Copy Markdown

Code Coverage

🎯 Code Coverage (details)
Patch Coverage: 90.00%
Overall Coverage: 40.82% (+0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2c74ee7 | Docs | Datadog PR Page | Give us feedback!

When DD_CSIDRIVER_WATCH_NAMESPACE differs from DD_AGENT_WATCH_NAMESPACE,
the owned DaemonSet falls outside DefaultNamespaces, causing cache errors.
Explicitly add DaemonSet to ByObject with the union of both namespace sets.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@tbavelier

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c74ee7e90

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/config/config.go
@tbavelier
tbavelier merged commit f41ef99 into main Apr 27, 2026
38 checks passed
@tbavelier
tbavelier deleted the tbavelier/add-cache-datadogcsidriver branch April 27, 2026 07:18
tbavelier added a commit that referenced this pull request Apr 27, 2026
…2940)

* Add DdCSIDriver cache env var

* Fix DaemonSet cache coverage for DatadogCSIDriver in separate namespace

When DD_CSIDRIVER_WATCH_NAMESPACE differs from DD_AGENT_WATCH_NAMESPACE,
the owned DaemonSet falls outside DefaultNamespaces, causing cache errors.
Explicitly add DaemonSet to ByObject with the union of both namespace sets.



---------


(cherry picked from commit f41ef99)

Co-authored-by: Timothée Bavelier <[email protected]>
Co-authored-by: Claude Sonnet 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants