Skip to content

Conversation

@cnmcavoy
Copy link
Contributor

Fixes N/A

Description

Adds two new prometheus metrics:

  • karpenter_nodepools_decisions
  • karpenter_nodepools_active_disruptions

karpenter_nodepools_decisions tracks the same actions as karpenter_voluntary_disruptions_decisions_total, but with an extra dimension for the nodepool. As a result, the total count of karpenter_nodepools_decisions may be greater than karpenter_voluntary_disruptions_decisions_total when 1 decision spans more than 1 nodepool.

karpenter_nodepools_active_disruptions tracks the active number of terminating nodeclaims in each nodepool, which is useful to compare against the existing metric karpenter_nodepools_allowed_disruptions.

This change allows us to track how disrupted individual nodepools are, and measure the consolidation in individual nodepools over time.

How was this change tested?

make presubmit and tested in our clusters.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cnmcavoy
Once this PR has been reviewed and has the lgtm label, please assign tzneal for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 11, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 20144144647

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 2 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.002%) to 80.33%

Files with Coverage Reduction New Missed Lines %
pkg/controllers/provisioning/scheduling/nodeclaim.go 3 89.63%
Totals Coverage Status
Change from base Build 19948193551: -0.002%
Covered Lines: 11880
Relevant Lines: 14789

💛 - Coveralls

ConsolidationTypeLabel: cmd.ConsolidationType(),
})
}
DecisionsPerformedTotal.Inc(map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just add a label to this metric instead of adding a new metric?

Copy link
Contributor Author

@cnmcavoy cnmcavoy Jan 5, 2026

Choose a reason for hiding this comment

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

I'm not sure I follow - are you thinking of using a label on DecisionsPerformedTotal? What about when a command includes multiple nodepools? The signature of the tags is map[string]string, it doesn't take an array of tags. Can we concat the nodepool names together? Open to ideas.

NodePoolAllowedDisruptions.Set(float64(allowedDisruptions), map[string]string{
metrics.NodePoolLabel: nodePool.Name, metrics.ReasonLabel: string(reason),
})
NodePoolActiveDisruptions.Set(float64(disrupting[nodePool.Name]), map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

This does technically include not ready nodes as well as ones that are disrupting. Does this number have use outside of knowing the end result of:

lo.Max([]int{allowedDisruptions - disrupting[nodePool.Name], 0})?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is intentional, the goal of this PR is to expose Karpenter's state to help operators understand it's decision making process.

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants