[CASCL-1323] Extract generic FindKarpenterInstallation helper#2970
Conversation
Replace install-specific FindForeignKarpenterInstallation with a generic FindKarpenterInstallation that returns the first Karpenter controller Deployment found, with InstalledBy / InstallerVersion sentinel labels captured. Foreign-vs-ours classification moves to the install caller (`\!k.IsOwn() || k.Namespace \!= karpenterNamespace`); install's behaviour table is preserved. The helper assumes at most one Karpenter per cluster — pinned by `first match wins when multiple Karpenters coexist`. Prepares the upcoming `kubectl datadog autoscaling cluster update` subcommand (separate PR), which needs the same scan but the inverse decision (require an install AND require it to be ours). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2970 +/- ##
=======================================
Coverage 41.41% 41.41%
=======================================
Files 331 331
Lines 28891 28895 +4
=======================================
+ Hits 11964 11967 +3
- Misses 16072 16073 +1
Partials 855 855
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
🎯 Code Coverage (details) 🔗 Commit SHA: 1086b72 | Docs | Datadog PR Page | Give us feedback! |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65d5b1ef0a
ℹ️ 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".
FindKarpenterInstallation helper
69ae116 to
46538ab
Compare
…tallation PR #2968 split install.go into multiple files; the foreign-Karpenter detection block and `displayForeignKarpenterMessage` moved to steps.go, and the matching tests moved to steps_test.go. Conflicts resolved by taking origin/main's slim install.go / install_test.go and re-applying this branch's `FindKarpenterInstallation` + `KarpenterInstallation` adaptation against the new locations (steps.go callsite + display signature; steps_test.go type + assertion message). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
46538ab to
1086b72
Compare
What does this PR do?
Extracts the Karpenter detection helper refactor from #2961 (
Add update subcommand to kubectl-datadog autoscaling cluster) so that PR can be split into reviewable chunks.guess.FindForeignKarpenterInstallation(ctx, clientset, targetNamespace) (*ForeignKarpenter, error)with a genericguess.FindKarpenterInstallation(ctx, clientset) (*KarpenterInstallation, error).InstalledBy,InstallerVersion) captured.IsOwn()method onKarpenterInstallation(kubectl-datadog vs third-party).Motivation
The future
kubectl datadog autoscaling cluster updatesubcommand (separate PR) needs the same cluster scan but the inverse decision (require an install AND require it to be ours). Sharing a single generic helper avoids duplicating the controller-detection logic.The helper assumes at most one Karpenter installation per cluster — install/update guards prevent multiple controllers coexisting in normal use. The trade-off is documented in the helper's doc comment and pinned by the
first match wins when multiple Karpenters coexistsubtest so it cannot drift silently.Additional Notes
This is a strict subset of #2961's
guess/karpenter.gochange plus the matching install callsite adjustment. None of #2961's other refactors (RunOptions/Run, IOStreams migration,KarpenterStackName/DDKarpenterStackName/DetectedInstallMode, theupdatecommand itself) ship here — they remain in #2961, which will rebase onmainonce this lands.The
InstallerVersionfield is populated but no current caller reads it; it's exposed now so the upcomingupdatePR doesn't need to come back and widen the struct.Minimum Agent Versions
N/A — kubectl plugin only.
Describe your test plan
make kubectl-datadogpasses lint (0 issues) and builds.go test ./cmd/kubectl-datadog/autoscaling/cluster/install/...is green, including the newTestFindKarpenterInstallation/first_match_wins_when_multiple_Karpenters_coexistsubtest andTestKarpenterInstallationIsOwn.git diff main -- cmd/kubectl-datadog/autoscaling/cluster/install/install.goshows only the foreign-detection block reshape and thedisplayForeignKarpenterMessageparameter type change — no other behavioural drift.Checklist
refactoringqa/skip-qalabel