Manage the kubectl-datadog OIDC provider in the CloudFormation stack #3632
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
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.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
AlexanderYastrebov
What does this PR do?
The IAM OIDC provider that the fargate install mode needs is now a resource of the
dd-karpenter-fargateCloudFormation stack. It used to be created in Go and was never deleted. Nowkubectl datadog autoscaling cluster uninstalldeletes it along with the stack, souninstallundoes exactly whatinstalldid.dd-karpenter-fargate.yamlgets a newOIDCProviderresource (AWS::IAM::OIDCProvider). It is only created when the newCreateOIDCProviderparameter istrue. The Karpenter IRSA role trusts either that provider or the one passed inOIDCProviderArn. ARulesassertion requiresOIDCProviderArnwhenCreateOIDCProviderisfalse.AWS::IAM::OIDCProviderfails withEntityAlreadyExistswhen a provider already exists for the issuer, which is common for clusters created with eksctl or already using IRSA.resolveOIDCProvider(apply/run.go) setsCreateOIDCProvider:- The stack already owns the provider (
CreateOIDCProvider=true): the parameter staystrue. Setting it tofalseon a laterinstallorupdatewould make CloudFormation delete the provider.- A provider already exists for the issuer: it is reused as before (
CreateOIDCProvider=false), and thests.amazonaws.comaudience is added to it if missing.- There is none: the stack creates it.
EnsureOIDCProvider, which created the provider and then waited for it to be readable, is replaced byReuseOIDCProvider, 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.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_autoscalingrun 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), ande2e_autoscalingfailed on every retry (e.g. #3576).Following @AlexanderYastrebov's suggestion, the provider is now managed by the stack.
Additional Notes
uninstallstill leaves them alone.uninstalltherefore needsiam:DeleteOpenIDConnectProvider. If stack tags are propagated to the provider,installalso needsiam:TagOpenIDConnectProvider.- 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-datadogplugin.Agent: N/A
Cluster Agent: N/A
Describe your test plan
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
CreateOIDCProviderexisted;- 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-lintpasses ondd-karpenter-fargate.yaml.e2e_autoscaling:verifyCleanUninstallalready checks that the stacks are gone afteruninstall, 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
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
🤖 Generated with Claude Code