Skip to content

Conditionally grant CSI driver RBAC to DCA#3270

Merged
levan-m merged 1 commit into
mainfrom
levan-m/csi-conditional-rbac
Jul 17, 2026
Merged

Conditionally grant CSI driver RBAC to DCA#3270
levan-m merged 1 commit into
mainfrom
levan-m/csi-conditional-rbac

Conversation

@levan-m

@levan-m levan-m commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

If user doesn't have CSI driver enabled (operator arg datadogCSIDriverEnabled, helm value datadogCSIDriver.enabled) Helm doesn't grant CSI-related RBAC to Operator but Operator still tries to grant it DCA leading to reconciler errors

{"level":"ERROR","ts":"2026-07-17T06:45:09.067Z","msg":"Reconciler error","namespace":"datadog-agent","name":"datadog-agent","reconcileID":"81333642-7596-45a6-a874-ceb5a1619d84","error":"[clusterroles.rbac.authorization.k8s.io "datadog-agent-cluster-agent" is forbidden: user "system:serviceaccount:datadog-agent:datadog-operator" (groups=["system:serviceaccounts" "system:serviceaccounts:datadog-agent" "system:authenticated"]) is attempting to grant RBAC permissions not currently held:\n{APIGroups:["storage.k8s.io"], Resources:["csidrivers"], ResourceNames:["k8s.csi.datadoghq.com"], Verbs:["get"]}\n{APIGroups:["storage.k8s.io"], Resources:["csidrivers"], Verbs:["list" "watch"

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

Install using helm and apply minimal DDA

❯ helm install datadog-operator datadog/datadog-operator \
--set datadogCSIDriver.enabled=false

Operator 1.28.0 will log above error. Version with a fix should not.

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)

@levan-m levan-m added this to the v1.29.0 milestone Jul 17, 2026
@levan-m
levan-m requested a review from a team July 17, 2026 07:44
@levan-m levan-m added the bug Something isn't working label Jul 17, 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: 22050162f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +86 to +87
if f.csiDriverEnabled {
clusterPolicyRules = append(clusterPolicyRules,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve CSI RBAC for externally managed drivers

When spec.global.csi.enabled=true but the CSI driver is installed externally, --datadogCSIDriverEnabled intentionally remains false—the supported behavior is documented in internal/controller/datadogagent/ddcsi.go:46-48. This condition therefore removes the Cluster Agent admission controller's permissions to discover that external CSIDriver, breaking CSI-based library injection in that configuration. Gate these rules on whether the DatadogAgent uses CSI (or otherwise preserve them for external installations), rather than on whether this operator manages the driver.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

no issue, when the flag is false Operator won't have sufficient RBAC to grant to DCA anyway.

@datadog-prod-us1-4

Copy link
Copy Markdown

Code Coverage

Fix all issues with BitsAI

🛑 Gate Violations

🎯 1 Code Coverage issue detected

A Patch coverage percentage gate may be blocking this PR.

Patch coverage: no data available (threshold: 80.00%)

ℹ️ Info

🎯 Code Coverage (details)
Patch Coverage: No data available
Overall Coverage: 46.91% (+0.01%)

Useful? React with 👍 / 👎

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

@levan-m
levan-m merged commit df5dfe5 into main Jul 17, 2026
44 of 45 checks passed
@levan-m
levan-m deleted the levan-m/csi-conditional-rbac branch July 17, 2026 13:06
@levan-m levan-m added backport label added by backport action backport/v1.29 and removed backport label added by backport action labels Jul 17, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 17, 2026

Copy link
Copy Markdown

The backport to v1.29 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-v1.29 v1.29
# Navigate to the new working tree
cd .worktrees/backport-v1.29
# Create a new branch
git switch --create backport-3270-to-v1.29
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 df5dfe5200339065772acdadc3b6f4a9ef662789
# Push it to GitHub
git push --set-upstream origin backport-3270-to-v1.29
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-v1.29

Then, create a pull request where the base branch is v1.29 and the compare/head branch is backport-3270-to-v1.29.

levan-m added a commit that referenced this pull request Jul 17, 2026
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.

2 participants