Skip to content

[Backport v1.26] Add cache namespace options for DatadogCSIDriver controller#2940

Merged
tbavelier merged 2 commits intov1.26from
backport-2934-to-v1.26
Apr 27, 2026
Merged

[Backport v1.26] Add cache namespace options for DatadogCSIDriver controller#2940
tbavelier merged 2 commits intov1.26from
backport-2934-to-v1.26

Conversation

@dd-octo-sts
Copy link
Copy Markdown

@dd-octo-sts dd-octo-sts Bot commented Apr 27, 2026

Backport f41ef99 from #2934.


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)

* 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.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit f41ef99)
@dd-octo-sts dd-octo-sts Bot added enhancement New feature or request backport label added by backport action bot label added by backport bot team/container-platform labels Apr 27, 2026
@dd-octo-sts dd-octo-sts Bot requested a review from a team as a code owner April 27, 2026 07:19
@dd-octo-sts dd-octo-sts Bot added bot label added by backport bot team/container-platform labels Apr 27, 2026
@dd-octo-sts dd-octo-sts Bot added this to the v1.26.0 milestone Apr 27, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 40.68%. Comparing base (e5cf461) to head (1da7286).

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

Impacted file tree graph

@@            Coverage Diff             @@
##            v1.26    #2940      +/-   ##
==========================================
+ Coverage   40.67%   40.68%   +0.01%     
==========================================
  Files         321      321              
  Lines       28482    28492      +10     
==========================================
+ Hits        11584    11593       +9     
- Misses      16043    16044       +1     
  Partials      855      855              
Flag Coverage Δ
unittests 40.68% <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 e5cf461...1da7286. Read the comment docs.

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

@tbavelier tbavelier merged commit 75232bf into v1.26 Apr 27, 2026
26 of 34 checks passed
@tbavelier tbavelier deleted the backport-2934-to-v1.26 branch April 27, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport label added by backport action bot label added by backport bot enhancement New feature or request team/container-platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants