Skip to content

Conversation

@L3n41c
Copy link
Member

@L3n41c L3n41c commented Dec 22, 2025

What does this PR do?

Add a subcommand to the kubectl plugin to uninstall Karpenter on a cluster:

kubectl datadog autoscaling cluster uninstall

Motivation

#2301 added a subcommand to install Karpenter.
This PR introduce a subcommend to do the reverse operation.

Additional Notes

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?
No

Describe your test plan

  • Create an EKS cluster;
  • Install Karpenter on it with kubectl datadog autoscaling cluster install;
  • Then validate that it can be uninstalled with kubectl datadog autoscaling cluster uninstall.

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

@L3n41c L3n41c added this to the v1.23.0 milestone Dec 22, 2025
@L3n41c L3n41c added enhancement New feature or request wip Work in progress component/plugin labels Dec 22, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 0% with 368 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.79%. Comparing base (490d736) to head (df49976).

Files with missing lines Patch % Lines
...datadog/autoscaling/cluster/uninstall/uninstall.go 0.00% 242 Missing ⚠️
...l-datadog/autoscaling/cluster/common/k8s/object.go 0.00% 33 Missing ⚠️
...datadog/autoscaling/cluster/common/aws/aws-auth.go 0.00% 29 Missing ⚠️
...g/autoscaling/cluster/common/aws/cloudformation.go 0.00% 29 Missing ⚠️
...tl-datadog/autoscaling/cluster/common/helm/helm.go 0.00% 16 Missing ⚠️
...ctl-datadog/autoscaling/cluster/install/install.go 0.00% 16 Missing ⚠️
cmd/kubectl-datadog/autoscaling/cluster/cluster.go 0.00% 1 Missing ⚠️
...og/autoscaling/cluster/install/k8s/ec2nodeclass.go 0.00% 1 Missing ⚠️
...atadog/autoscaling/cluster/install/k8s/nodepool.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2424      +/-   ##
==========================================
- Coverage   37.32%   36.79%   -0.53%     
==========================================
  Files         290      291       +1     
  Lines       24720    25072     +352     
==========================================
  Hits         9226     9226              
- Misses      14781    15133     +352     
  Partials      713      713              
Flag Coverage Δ
unittests 36.79% <0.00%> (-0.53%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/kubectl-datadog/autoscaling/cluster/cluster.go 0.00% <0.00%> (ø)
...og/autoscaling/cluster/install/k8s/ec2nodeclass.go 0.00% <0.00%> (ø)
...atadog/autoscaling/cluster/install/k8s/nodepool.go 0.00% <0.00%> (ø)
...tl-datadog/autoscaling/cluster/common/helm/helm.go 0.00% <0.00%> (ø)
...ctl-datadog/autoscaling/cluster/install/install.go 12.76% <0.00%> (-0.14%) ⬇️
...datadog/autoscaling/cluster/common/aws/aws-auth.go 32.69% <0.00%> (ø)
...g/autoscaling/cluster/common/aws/cloudformation.go 0.00% <0.00%> (ø)
...l-datadog/autoscaling/cluster/common/k8s/object.go 0.00% <0.00%> (ø)
...datadog/autoscaling/cluster/uninstall/uninstall.go 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 490d736...df49976. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@L3n41c L3n41c force-pushed the lenaic/CASCL-647_karpenter_uninstaller branch from be38b1c to 03da607 Compare December 22, 2025 16:21
@L3n41c
Copy link
Member Author

L3n41c commented Dec 22, 2025

@codex review

@L3n41c L3n41c force-pushed the lenaic/CASCL-647_karpenter_uninstaller branch from 03da607 to f208c10 Compare December 22, 2025 16:24
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@L3n41c
Copy link
Member Author

L3n41c commented Dec 23, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment on lines +164 to +168
if err = deleteKarpenterNodePools(ctx, clients); err != nil {
log.Printf("Warning: failed to delete NodePools: %v", err)
}

if err = deleteKarpenterEC2NodeClasses(ctx, clients); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail uninstall when cleanup steps error

Errors from each cleanup step are only logged and ignored (deleteKarpenterNodePools/deleteKarpenterEC2NodeClasses at these lines), yet the command later prints a success banner and returns nil. If the user lacks RBAC or CRDs are missing, those deletions will fail but the CLI will still exit 0, leaving Karpenter resources and AWS infrastructure behind with no signal to automation that the uninstall was incomplete. This should surface failures rather than treating them as warnings.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/plugin enhancement New feature or request wip Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants