Fix PAR enrollment identity secret permissions #3678
All Vouch review confidence checks passed
Residual risk 0.32 = Change Risk (0.80) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.80 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.080
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3678"
general
weight: 0.35
dd-gplassard
What does this PR do?
Follow-up to merged #3623. Rebased onto
mainafter #3623 merged. The final source tree and follow-up diff are unchanged by the rebase.Fix the two remaining Cluster Agent PAR enrollment RBAC defects found during fresh-cluster QA:
private-action-runner-identity.identity_secret_namefrom Kubernetes Actions-generated configuration so Kubernetes Actions and direct PAR configuration use the same Agent default. Explicit user-supplied names remain unchanged.createpermission from name-restrictedget/updatepermissions.Motivation
#3623 correctly provisions enrollment RBAC when
self_enrollis omitted, but fresh enrollment still fails:1. The old default Role names
datadog-private-action-runner-identity, while the Agent requestsprivate-action-runner-identity, so its initial GET is forbidden.2. With a custom name (including explicit
self_enroll: truebefore #3623), enrollment reaches Datadog, but persisting the identity fails. Kubernetes does not authorize CREATE requests using aresourceNames-restricted rule.Both defects predate #3623. This follow-up makes the intended default enrollment path work end to end.
Additional Notes
Security scope: Kubernetes cannot restrict secret creation by resource name. The new create-only rule permits creating secrets in the DDA namespace, not other namespaces. Get/update remain restricted to the configured identity secret. This change adds no list, watch, delete, or patch permissions. The Cluster Agent may already receive other permissions from unrelated roles; the enrollment Role was also tested in isolation.
This PR does not change how PAR is enabled (annotation or Kubernetes Actions). Explicit
self_enroll: false, feature-disabled behavior, user-supplied configuration, node Agent behavior, and remediation permissions are unchanged. File-backed identities receive no enrollment-secret Role/RoleBinding. No CRD changes or dependencies.RC/nightly compatibility: The Kubernetes Actions-generated secret name was introduced in #3618 and is absent from stable v1.31.2, but present in v1.32.0-rc.1. Following review, this PR removes that generated name rather than preserving two defaults. Existing RC/nightly installations that need to keep their old enrollment should explicitly set
identity_secret_name: datadog-private-action-runner-identityin their PAR configdata. There is no automatic migration of the old secret. The earlier legacy-name preservation experiment is superseded by this approach.Minimum Agent Versions
No new minimum introduced. Live validation used Cluster Agent 7.84.1; other Agent versions were not exercised.
Describe your test plan
TZ=UTC go test ./internal/controller/datadogagent/feature/privateactionrunner -race -count=1.TZ=UTC go test ./... ./api/....make lint(zero issues).- No config annotation, minimal config, omitted setting + custom identity secret, explicit true, and null: enrollment succeeds and identity is persisted.
- Explicit false and feature disabled: no enrollment Role/Binding. No manual identity was supplied for the false case; complete manual enrollment is not claimed.
- Default/custom identities survive pod restart without re-enrollment; secret UID and identity data remain unchanged.
- Isolated generated Role: create in its namespace and get/update of its identity secret succeed; unrelated-secret get/update, list/watch/delete, and cross-namespace create are denied.
- File storage with omitted and explicit-true self-enrollment: runner enrolled and started, nonempty identity file existed, no enrollment Role/Binding, and secret creation was denied.
- Explicitly enabled remediation ClusterRole/Binding remained present in the file-storage case.
- Fresh Kubernetes Actions-only enrollment persists identity in
private-action-runner-identity, with noidentity_secret_namein generated YAML.- Add the explicit PAR enable annotation; supply partial PAR config without a secret name; disable Kubernetes Actions while retaining direct PAR; switch back to Kubernetes Actions only.
- Every transition followed by a pod restart reuses the same secret UID, URN, and private key without re-enrollment or creation of the old-name secret.
- The default-name regression test fails before this final change and passes afterward. Full Go tests, PAR race tests, and lint pass.
Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits