Let the Agent own PAR self-enrollment defaults #3623
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"34b80951b5faa332c4c4f85f2cda8aa5ff9faf98","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-10-19T14:48:43.455143Z">2026-10-19T14:48:43.455143Z</relative-time> | 34b8095 | Draft marked ready |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
<sub><sub>!P2 Badge</sub></sub> Avoid secret RBAC when file identity storage is selected
When self_enroll is omitted but identity_use_k8s_secret: false is explicitly configured, this default now makes SelfEnroll true, and ManageDependencies gates enrollment RBAC only on that field (feature.go:176). The resulting Role grants the Cluster Agent access to the default or configured identity Secret even though the runner is configured to persist its identity to a file; include the effective IdentityUseK8sSecret value in the RBAC condition to avoid granting unnecessary access.
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<!-- codex-review-receipt:v1 -->
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34b80951b5
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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".
</details>
<a target='_blank' href='https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob+%40git.commit.sha%3A8140a6e491b6df563543aa2b12d686f54099131e&referrer=pr-comment&start=1793227191000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok-light.svg" alt="Pipelines" align="center" /></picture></a> <a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3623'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-ok-light.svg" alt="Code Coverage" align="center" /></picture></a>
🎯 Code Coverage (<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3623'>details</a>)<br>• <strong><span title="Percentage of modified executable lines covered by tests in this PR">Patch Coverage</span></strong>: 100.00%<br>• <strong><span title="Percentage of all executable lines covered by tests in the entire codebase">Overall Coverage</span></strong>: 56.98% <span title="Change in overall coverage compared to the base branch">(+0.02%)</span><br>
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: 8140a6e | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>
Approved these changes.
Approved these changes.
dd-gplassard
julesmcrt
What does this PR do?
Leave
private_action_runner.self_enrollunset when omitted, so the Agent owns its runtime default rather than the Operator duplicating it.Represent the setting as an optional boolean. Preserve explicit
trueandfalse, and omit the environment variable when unset. Provision the existing Cluster Agent enrollment-secret Role and RoleBinding unless self-enrollment or Kubernetes identity storage is explicitly disabled. The mounted configuration YAML remains unchanged.Motivation
The Agent already defaults self-enrollment to true, but the Operator decoded an omitted value into a zero-valued Go bool. Since that value gates enrollment RBAC creation, the Operator could omit the enrollment permissions even while the Agent attempted to self-enroll.
Additional Notes
This change does not alter how PAR is enabled (annotations or Kubernetes Actions), RBAC policy contents, split mode, or node Agent configuration. File-backed identities receive no enrollment-secret Role/RoleBinding; separately enabled remediation permissions are preserved. Existing permissions may mask the mismatch in an already-configured cluster.
Companion Helm change: DataDog/helm-charts#2986. Neither integration should override an omitted Agent setting.
Minimum Agent Versions
No new minimum versions introduced. Runtime behavior for an omitted setting remains determined by the selected Agent version.
Describe your test plan
TZ=UTC go test ./internal/controller/datadogagent/feature/privateactionrunner -race -count=1.go test ./internal/controller/datadogagent/feature/privateactionrunner -count=1make lint(zero issues)TZ=UTC go test ./... ./api/...The initial full-suite run in the local timezone failed in unrelated
Test_getDashboardandTest_getMonitortime-location comparisons; the UTC run passed. Subsequent live before/after QA on Kind/Kubernetes 1.34 with Cluster Agent 7.84.1 confirmed the missing-Role regression and this PR's gating fix. Fresh enrollment still encounters pre-existing secret-name/create-permission defects, addressed in stacked PR #3678; this PR alone is not an end-to-end enrollment fix. File-backed enrollment and preservation of remediation permissions were live-tested in the combined stack. The latest parent-only file-storage change was validated with regression tests, race tests, the full Go suite, and lint.Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits