← Back to Pull requests

Fix PAR enrollment identity secret permissions #3678

Closed
unknown closed this pull request without merging on Oct 29, 2026 16:05 UTC
View on GitHub
unknown unknown commented on Oct 28, 2026 12:44 UTC
Author

What does this PR do?

Follow-up to merged #3623. Rebased onto main after #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:

  • Match the Agent's default identity-secret name for omitted settings: private-action-runner-identity.

  • Omit identity_secret_name from Kubernetes Actions-generated configuration so Kubernetes Actions and direct PAR configuration use the same Agent default. Explicit user-supplied names remain unchanged.

  • Separate namespace-scoped secret create permission from name-restricted get/update permissions.

  • Retain the file-storage RBAC guard and remediation-permission regression coverage already merged in #3623.

  • Add regression coverage for exact rules, default-name omission, and explicit legacy-name overrides.
  • Motivation

    #3623 correctly provisions enrollment RBAC when self_enroll is omitted, but fresh enrollment still fails:

    1. The old default Role names datadog-private-action-runner-identity, while the Agent requests private-action-runner-identity, so its initial GET is forbidden.
    2. With a custom name (including explicit self_enroll: true before #3623), enrollment reaches Datadog, but persisting the identity fails. Kubernetes does not authorize CREATE requests using a resourceNames-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-identity in 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

  • Updated regression tests fail on #3623's head before this fix and pass afterward.

  • Passed: TZ=UTC go test ./internal/controller/datadogagent/feature/privateactionrunner -race -count=1.

  • Passed: TZ=UTC go test ./... ./api/....

  • Passed: make lint (zero issues).

  • Live QA: exact Linux Operator binary against Kind/Kubernetes 1.34 on a GCP VM, fresh namespaces, identical Cluster Agent 7.84.1 image, API-key-only US1 enrollment. No diagnostic grants on the Cluster Agent service accounts.

  • - 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.
  • Follow-up live QA for the review fixes, on the updated main-based branch:

  • - 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.
  • Final live QA for the unified default:

  • - Fresh Kubernetes Actions-only enrollment persists identity in private-action-runner-identity, with no identity_secret_name in 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.
  • Operator container packaging, node/split mode, other Agent versions, and automatic RC/nightly identity migration were not live-tested.
  • 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][1])
  • [1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: dd-gplassard Review duration: 1641m
    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
    0.80
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 80.2% (HIGH) · Higher = larger blast radius
    80.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 31.7% · Safe to merge
    31.7%