Skip to content

Conversation

@seanlaii
Copy link
Contributor

@seanlaii seanlaii commented Oct 21, 2025

What type of PR is this?
/kind feature

What this PR does / why we need it:
Add EstimateComponentsPlugins support to estimator framework to allow customizing scheduling logic for Components.

Which issue(s) this PR fixes:

Part of #6734

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-scheduler-estimator`: Allow adding plugins in estimator for component scheduling.
`karmada-scheduler-estimator`: Deprecated the `Estimator` label value for `estimating_plugin_extension_point` in the `estimating_plugin_execution_duration_seconds` and `estimating_plugin_extension_point_duration_seconds` metrics. Use `estimate_replicas` instead; `Estimator` will be removed in a future release. To avoid double counting during the deprecation period, update PromQL to filter on `estimating_plugin_extension_point="estimate_replicas"` (or exclude `Estimator`).

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 21, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @seanlaii, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the estimator framework by introducing a new plugin extension point for EstimateComponentsPlugins. This allows for greater flexibility and customization in defining the scheduling logic for component sets, enabling users to implement their own strategies for estimating the maximum number of complete component sets based on given requirements. The changes include interface definitions, core framework implementation, and robust testing to ensure proper functionality and integration.

Highlights

  • New Plugin Extension Point: Introduced EstimateComponentsPlugins to the estimator framework, allowing for custom scheduling logic when estimating component sets.
  • Framework Interface Update: The Framework interface now includes RunEstimateComponentsPlugins and the EstimateComponentsPlugin interface for defining component set estimation logic.
  • Implementation and Metrics: The frameworkImpl now supports registering and running EstimateComponentsPlugins, with updated metrics to track their execution, ensuring backward compatibility with existing EstimateReplicas metrics.
  • Comprehensive Testing: New unit tests have been added to validate the behavior of RunEstimateComponentsPlugins under various scenarios, including success, error, unschedulable, and no-operation results from plugins.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 21, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for EstimateComponentsPlugins to the estimator framework, a valuable feature for customizing component scheduling logic. The implementation is well-aligned with the existing EstimateReplicasPlugins framework, covering new interfaces, framework logic, and metrics. The test coverage for the new functionality is also thorough. I have a couple of suggestions: one to clarify a comment in the new interface and another to fix a bug in a new test case related to loop variable capturing, which would improve the reliability of the tests. Overall, this is a solid contribution.

// Emit metrics with both old and new labels for backward compatibility
// TODO: Remove estimator label in a future release (deprecated)
metrics.FrameworkExtensionPointDuration.WithLabelValues(estimator).Observe(utilmetrics.DurationInSeconds(startTime))
metrics.FrameworkExtensionPointDuration.WithLabelValues(estimateReplicasExtension).Observe(utilmetrics.DurationInSeconds(startTime))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @RainbowMango ,

In order to differentiate the metrics between EstimateReplica and EstimateComponents plugins, I decided to introduce a new metrics with EstimateComponents label and plan to use EstimateReplica to replace the old Estimator label.

Additionally, to avoid breaking change I decided to emit the same metrics twice but with different label.
What do you think? I am OK with reusing Estimator but EstimateReplica might be clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with introducing EstimateReplica to replace Estimator. However, if we proceed with this change, the release note should include an additional section on the deprecation of the existing metrics.

Copy link
Member

Choose a reason for hiding this comment

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

I'm OK with this way by introducing a new metric to deprecate the old one.

+1 on the release note

In addition, I realized both the old and new label names are written in camel case, which is not recommended.
I failed to find some documentation about the naming rule, but there is a metrics linter in the Prometheus project:
https://github.com/RainbowMango/client_golang/blob/e729ba11961abb3a50910c324221d06a35bdce4f/prometheus/testutil/promlint/validations/generic_name_validations.go#L74-L89

PS: I introduced this tool to Kubernetes several years ago, but I didn't get a chance to do the same thing in Karmada. I think Karmada should adopt this tool as well.

Copy link
Contributor Author

@seanlaii seanlaii Oct 22, 2025

Choose a reason for hiding this comment

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

Thanks for the info! Updated the label values with snake case and the release note.

Copy link
Member

Choose a reason for hiding this comment

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

In addition, I realized both the old and new label names are written in camel case, which is not recommended.

Hey, I need to correct my previous comment about the label format, according to the validation tools I linked above, only the label name should be written in snake_case. Actually, what we are talking about here is the value, I don't see any rules for it.

I see you updated the label value to snake_case, which also looks fine to me.

@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.67%. Comparing base (ce66819) to head (7df8e9e).
⚠️ Report is 2 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6864      +/-   ##
==========================================
+ Coverage   45.63%   45.67%   +0.04%     
==========================================
  Files         692      692              
  Lines       57703    57732      +29     
==========================================
+ Hits        26331    26371      +40     
+ Misses      29725    29716       -9     
+ Partials     1647     1645       -2     
Flag Coverage Δ
unittests 45.67% <100.00%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@seanlaii seanlaii force-pushed the component-framework branch from 8f1b070 to c8e9577 Compare October 21, 2025 19:27
@seanlaii
Copy link
Contributor Author

cc @RainbowMango @mszacillo

@zhzhuang-zju
Copy link
Contributor

Thanks
/assign

@zhzhuang-zju
Copy link
Contributor

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 22, 2025
@RainbowMango RainbowMango added this to the v1.16 milestone Oct 22, 2025
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/assign

Signed-off-by: seanlaii <qazwsx0939059006@gmail.com>
@seanlaii seanlaii force-pushed the component-framework branch from c8e9577 to 7df8e9e Compare October 22, 2025 15:40
@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 22, 2025
@zhzhuang-zju
Copy link
Contributor

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 23, 2025
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

The pull request process is described 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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 23, 2025
@karmada-bot karmada-bot merged commit 776d7ee into karmada-io:master Oct 23, 2025
24 checks passed
@seanlaii seanlaii deleted the component-framework branch October 23, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. 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.

5 participants