Skip to content

perf: Add flag to disable costly metrics controllers #2354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DerekFrank
Copy link
Contributor

@DerekFrank DerekFrank commented Jul 7, 2025

Fixes #N/A

Description

Metrics controllers can cause metric scrape timeouts at scale, this adds an optional feature flag to disable them

How was this change tested?

make presubmit

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 7, 2025
@k8s-ci-robot k8s-ci-robot requested a review from engedaam July 7, 2025 20:37
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: DerekFrank
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.

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 requested a review from tallaxes July 7, 2025 20:37
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 7, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @DerekFrank. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 7, 2025
@coveralls
Copy link

coveralls commented Jul 7, 2025

Pull Request Test Coverage Report for Build 16630012081

Details

  • 1 of 15 (6.67%) changed or added relevant lines in 2 files are covered.
  • 10 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.1%) to 81.782%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/controllers/controllers.go 0 14 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/test/expectations/expectations.go 2 93.37%
pkg/controllers/disruption/consolidation.go 4 88.14%
pkg/controllers/provisioning/scheduling/topologydomaingroup.go 4 86.21%
Totals Coverage Status
Change from base Build 16532859399: -0.1%
Covered Lines: 10464
Relevant Lines: 12795

💛 - Coveralls

Copy link

@tallaxes tallaxes left a comment

Choose a reason for hiding this comment

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

Would be good to list exactly what would be missing/disabled when this flag is used.

@@ -99,25 +96,16 @@ func NewControllers(
nodeclaimdisruption.NewController(clock, kubeClient, cloudProvider),
nodeclaimhydration.NewController(kubeClient, cloudProvider),
nodehydration.NewController(kubeClient, cloudProvider),
status.NewController[*v1.NodeClaim](
Copy link

Choose a reason for hiding this comment

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

Are these status controllers only responsible for metrics? Anything else would be missing by disabling them? (For example, looks like they also issue transition events ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They do also emit events for finalizers and status condition changes, but I think thats all they emit

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 26, 2025
@DerekFrank
Copy link
Contributor Author

This option will disable all of the metrics that are just observing cluster state:

  • karpenter_node_allocatable
  • karpenter_node_total_pod_requests
  • karpenter_node_total_pod_limits
  • karpenter_node_total_daemon_requests
  • karpenter_node_total_daemon_limits
  • karpenter_node_system_overhead
  • karpenter_node_current_lifetime_seconds
  • karpenter_nodepool_limit
  • karpenter_nodepool_usage
  • karpenter_pod_state
  • karpenter_pod_startup_duration_seconds
  • karpenter_pod_unstarted_time_seconds
  • karpenter_pod_bound_duration_seconds
  • karpenter_pod_unbound_time_seconds
  • karpenter_pod_provisioning_bound_duration_seconds
  • karpenter_pod_provisioning_unbound_time_seconds
  • karpenter_pod_provisioning_startup_duration_seconds
  • karpenter_pod_provisioning_unstarted_time_seconds
  • karpenter_pod_provisioning_scheduling_undecided_time_seconds
  • operator_nodeclaim_status_condition_transition_seconds
  • operator_nodeclaim_status_condition_count
  • operator_nodeclaim_status_condition_current_status_seconds
  • operator_nodeclaim_status_condition_transitions_total
  • operator_nodepool_status_condition_transition_seconds
  • operator_nodepool_status_condition_count
  • operator_nodepool_status_condition_current_status_seconds
  • operator_nodepool_status_condition_transitions_total
  • operator_nodeclass_status_condition_transition_seconds
  • operator_nodeclass_status_condition_count
  • operator_nodeclass_status_condition_current_status_seconds
  • operator_nodeclass_status_condition_transitions_total

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 30, 2025
@@ -85,6 +85,7 @@ type Options struct {
minValuesPolicyRaw string
MinValuesPolicy MinValuesPolicy
FeatureGates FeatureGates
SimplifiedMetrics bool
Copy link
Member

Choose a reason for hiding this comment

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

We should figure out a more descriptive name than SimplifiedMetrics. Minimally, I think it should be clear from the name of the flag which metrics we're disabling. I'm thinking we could have something along the lines of DisableClusterStateMetrics and DisableStatusConditionMetrics.

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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

6 participants