Skip to content

Conversation

@tiraboschi
Copy link
Contributor

@tiraboschi tiraboschi commented Sep 9, 2025

Enhance the plugin interface introducing an additional Metrics interface to be easily implemented by plugins
that intend to register and expose metrics.

Expose two new metrics from the LowNodeUtilization plugin:

  • descheduler_low_node_utilization_thresholds
  • descheduler_low_node_utilization_classification

These metrics allow users to properly monitor plugin behavior,
which was previously only visible in descheduler logs.

@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 Sep 9, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @tiraboschi. 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 Sep 9, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign damemi 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 added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 9, 2025
LoopDuration,
StrategyDuration,
LowNodeUtilizationThresholds,
LowNodeUtilizationClassification,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not scale well for external plugins. Maybe a combination of init() and metrics registration within each plugin? Or, have you tried to invoke RegisterMetrics within the plugin instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I tried adding an optional Metrics interface to complement Handle without breaking backward compatibility

for key, rt := range thresholds {
for i, t := range rt {
for resource, value := range t {
metrics.LowNodeUtilizationThresholds.WithLabelValues(key, strconv.Itoa(i), resource.String()).Set(float64(value))
Copy link
Contributor

Choose a reason for hiding this comment

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

There could be a new handler for setting metrics. E.g. l.handle.Metric(metricsName).WithLabelValues or similar that would be a no-op in case metrics are not enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I implemented a new metric handler wrapping all the metric setters embedding there the skip metric setting.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 10, 2025

// RegisterMetrics registers the plugin's metrics
func (l *LowNodeUtilization) RegisterMetrics() {
RegisterMetrics(metrics.PluginRegistry)
Copy link
Contributor

@ingvagabund ingvagabund Sep 15, 2025

Choose a reason for hiding this comment

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

There's probably no way to disallow users to invoke this in the NewXXX functions. Also, the descheduler registers the metrics independent of whether metrics server is enabled or not. I wonder what would be the overhead of just registering the metrics directly. Allowing to skip ShouldExport logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, a single plugin can be initialized in each profile. Thus, a metric entry needs to be labeled with a profile name as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a bit of logic to register metrics by profile name and by plugin name.
A metric named Classification registered by LowNodeUtilization plugin required by CustomProfile profile will result in descheduler_custom_profile_low_node_utilization_classification.

Enhance the plugin interface introducing an additional
Metrics interface to be easily implemented by plugins
that intend to register and expose metrics.

Expose two new metrics from the LowNodeUtilization plugin:
- low_node_utilization_thresholds
- low_node_utilization_classification

These metrics allow users to properly monitor plugin behavior,
which was previously only visible in descheduler logs.

Signed-off-by: Simone Tiraboschi <[email protected]>
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants