← Back to Pull requests

Manage the kubectl-datadog OIDC provider in the CloudFormation stack #3632

Closed
unknown closed this pull request without merging on Oct 22, 2026 16:15 UTC
View on GitHub
unknown unknown commented on Oct 20, 2026 17:21 UTC
Author

What does this PR do?

The IAM OIDC provider that the fargate install mode needs is now a resource of the dd-karpenter-fargate CloudFormation stack. It used to be created in Go and was never deleted. Now kubectl datadog autoscaling cluster uninstall deletes it along with the stack, so uninstall undoes exactly what install did.

  • Template: dd-karpenter-fargate.yaml gets a new OIDCProvider resource (AWS::IAM::OIDCProvider). It is only created when the new CreateOIDCProvider parameter is true. The Karpenter IRSA role trusts either that provider or the one passed in OIDCProviderArn. A Rules assertion requires OIDCProviderArn when CreateOIDCProvider is false.

  • Why the resource is conditional: AWS::IAM::OIDCProvider fails with EntityAlreadyExists when a provider already exists for the issuer, which is common for clusters created with eksctl or already using IRSA. resolveOIDCProvider (apply/run.go) sets CreateOIDCProvider:

  • - The stack already owns the provider (CreateOIDCProvider=true): the parameter stays true. Setting it to false on a later install or update would make CloudFormation delete the provider.
    - A provider already exists for the issuer: it is reused as before (CreateOIDCProvider=false), and the sts.amazonaws.com audience is added to it if missing.
    - There is none: the stack creates it.
  • Go code: EnsureOIDCProvider, which created the provider and then waited for it to be readable, is replaced by ReuseOIDCProvider, which only looks the provider up. The lookup now matches providers on the URL embedded in their ARN, and only describes the provider that matches instead of describing every provider in the account.

  • Not affected: the existing-nodes mode (dd-karpenter.yaml) uses EKS Pod Identity, which needs no OIDC provider.
  • Motivation

    EKS Pod Identity is not available on Fargate. The fargate mode, which is the default, therefore uses IRSA and needs an IAM OIDC provider for the cluster's issuer.

    Until now that provider was created outside of CloudFormation and never deleted. Deleting the EKS cluster doesn't delete it either. Every e2e_autoscaling run creates a new cluster, so each run leaked one provider in the CI account. The account eventually hit its quota (LimitExceeded: Cannot exceed quota for OpenIdConnectProvidersPerAccount: 100), and e2e_autoscaling failed on every retry (e.g. #3576).

    Following @AlexanderYastrebov's suggestion, the provider is now managed by the stack.

    Additional Notes

  • Known trade-off: a provider created by the stack is deleted with it, even if IRSA roles of other workloads started trusting it after the install. There is a single provider per issuer, and other tools reuse whichever one exists.

  • Not cleaned up: providers created outside of CloudFormation by previous versions are treated as pre-existing, so uninstall still leaves them alone.

  • IAM permissions: CloudFormation now creates and deletes the provider with the caller's credentials. uninstall therefore needs iam:DeleteOpenIDConnectProvider. If stack tags are propagated to the provider, install also needs iam:TagOpenIDConnectProvider.

  • Still to verify on a real fresh fargate install:

  • - CloudFormation must create the IRSA role right after the provider without an IAM propagation error. In Go this was handled by a polling wait, which is now gone.
    - The tag propagation mentioned above.

    Minimum Agent Versions

    No requirement: this change only affects the kubectl-datadog plugin.

    Agent: N/A
    Cluster Agent: N/A

    Describe your test plan

  • Unit tests (go test ./cmd/kubectl-datadog/autoscaling/cluster/...):

  • - TestResolveOIDCProvider:
    - fresh install, with and without an existing provider;
    - provider owned by the stack keeps being owned;
    - reused provider keeps being reused;
    - stack created before CreateOIDCProvider existed;
    - lookup errors.
    - TestReuseOIDCProvider: ARN-based matching (host case-insensitive, path case-sensitive), only the matching provider is described, STS audience patching, provider deleted between list and get, errors.
  • cfn-lint passes on dd-karpenter-fargate.yaml.

  • e2e e2e_autoscaling: verifyCleanUninstall already checks that the stacks are gone after uninstall, which now covers the provider. This needs the CI account's leaked providers to be cleaned up first, as the quota is currently reached.
  • 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

    🤖 Generated with Claude Code

    Diff: 611 lines (+458 / -153) across 7 files Reviewer: AlexanderYastrebov Review duration: 2814m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.73) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.73 · 611 lines diff across 7 files
    0.73
    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.384
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.073
    Real PR Conversation Timeline
    1 comments
    "Review active on #3632"
    general weight: 0.35
    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: 73.4% (HIGH) · Higher = larger blast radius
    73.4%
    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: 29.0% · Safe to merge
    29.0%