Skip to content

Conversation

@RainbowMango
Copy link
Member

@RainbowMango RainbowMango commented Nov 20, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

This pull request refactors the gRPC interface for multi-component set estimation by introducing a dedicated ComponentReplicaRequirements message and moving the namespace field to the top-level request. The changes are consistently applied across the client, server, framework, and plugins, improving the API design.

Which issue(s) this PR fixes:
Fixes #
Part of #6734

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Copilot AI review requested due to automatic review settings November 20, 2025 10:23
@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 20, 2025
@karmada-bot karmada-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 20, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @RainbowMango, 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 refactors the gRPC interface for multi-component set estimation by introducing a more granular ComponentReplicaRequirements structure. This change enhances the clarity and completeness of replica requirement specifications, particularly for resource and scheduling constraints. It also ensures that namespace information is consistently available throughout the estimation process, which is crucial for accurate resource quota evaluations in target member clusters.

Highlights

  • New ComponentReplicaRequirements Structure: A dedicated ComponentReplicaRequirements message has been introduced in the gRPC interface to encapsulate per-replica resource requirements, node claims, and priority class names for component set estimation.
  • Namespace Parameter for Estimation: The MaxAvailableComponentSetsRequest gRPC message now includes a Namespace field, which is explicitly passed to the estimation framework and its plugins for accurate resource quota checks.
  • Refactored toPBReplicaRequirements Function: The toPBReplicaRequirements helper function has been updated to convert to the new pb.ComponentReplicaRequirements type and no longer requires the namespace as a direct argument, as this information is now part of the request or the new structure.
  • Updated Estimation Framework Interfaces: The core estimation framework and its plugins (e.g., noderesource, resourcequota) have been modified to accept the namespace parameter directly in their EstimateComponents methods, ensuring proper context for quota evaluations.
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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the multi-component set estimation interface by introducing a dedicated ComponentReplicaRequirements type and moving the namespace parameter from component-level to request-level. This change simplifies the API design by removing namespace from individual component requirements and instead passing it once at the request level.

Key changes:

  • Introduced new ComponentReplicaRequirements type to replace ReplicaRequirements in component definitions
  • Added Namespace field to MaxAvailableComponentSetsRequest
  • Updated all plugin interfaces and implementations to accept namespace as a parameter

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/estimator/pb/types.go Introduced ComponentReplicaRequirements type; added namespace field to request
pkg/estimator/pb/generated.proto Updated proto definitions for new types
pkg/estimator/pb/generated.pb.go Auto-generated code for new proto definitions
pkg/estimator/server/framework/interface.go Added namespace parameter to plugin interface methods
pkg/estimator/server/framework/runtime/framework.go Threaded namespace parameter through plugin execution
pkg/estimator/server/framework/runtime/framework_test.go Updated test to pass namespace parameter
pkg/estimator/server/framework/plugins/noderesource/noderesource.go Added namespace parameter (unused)
pkg/estimator/server/framework/plugins/noderesource/noderesource_test.go Updated tests with new type and namespace parameter
pkg/estimator/server/framework/plugins/resourcequota/resourcequota.go Uses namespace from parameter instead of component field
pkg/estimator/server/framework/plugins/resourcequota/resourcequota_test.go Updated tests with new type and namespace field
pkg/estimator/server/estimate.go Passes namespace from request to estimation method
pkg/estimator/client/accurate.go Builds request with namespace at request level

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Replicas int32 `json:"replicas" protobuf:"varint,3,opt,name=replicas"`
}

// ComponentReplicaRequirements represents the requirements required by each replica.
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The documentation comment is redundant ('requirements required'). Consider rephrasing to 'ComponentReplicaRequirements represents the resource and scheduling requirements for each replica.'

Suggested change
// ComponentReplicaRequirements represents the requirements required by each replica.
// ComponentReplicaRequirements represents the resource and scheduling requirements for each replica.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated as suggested.

But hope to start another PR to fix the other places.

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 refactors the gRPC interface for multi-component set estimation by introducing a dedicated ComponentReplicaRequirements message and moving the namespace field to the top-level request. The changes are consistently applied across the client, server, framework, and plugins, improving the API design. I've identified a potential issue with handling an empty namespace in the resource quota estimator and suggested improvements for comment clarity in the protobuf definitions.

@RainbowMango RainbowMango force-pushed the pr_optimize_estimator_grpc branch from 58f128a to 52aaeba Compare November 20, 2025 11:57
@RainbowMango RainbowMango added this to the v1.16 milestone Nov 20, 2025
@RainbowMango
Copy link
Member Author

cc @mszacillo @seanlaii

@codecov-commenter
Copy link

codecov-commenter commented Nov 20, 2025

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

Codecov Report

❌ Patch coverage is 45.00000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.44%. Comparing base (1d5f925) to head (71d335a).

Files with missing lines Patch % Lines
pkg/estimator/client/accurate.go 0.00% 5 Missing ⚠️
pkg/estimator/server/estimate.go 0.00% 3 Missing ⚠️
...r/framework/plugins/resourcequota/resourcequota.go 57.14% 2 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6939      +/-   ##
==========================================
- Coverage   46.45%   46.44%   -0.01%     
==========================================
  Files         698      698              
  Lines       47809    47811       +2     
==========================================
  Hits        22208    22208              
- Misses      23930    23932       +2     
  Partials     1671     1671              
Flag Coverage Δ
unittests 46.44% <45.00%> (-0.01%) ⬇️

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.

namespace := components[0].ReplicaRequirements.Namespace
if namespace == "" {
klog.V(5).Infof("%s: namespace is empty, skipping resource quota check", pl.Name())
return noQuotaConstraint, framework.NewResult(framework.Success)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! LGTM overall.
Only one thing from me, after checking the nooperation definition: Nooperation is used when a plugin is disabled or the plugin list is empty, I think we might need to change the status code on line 145 to Success.
Could you help change it in this PR? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, forgot to mention that we also need to change the test here.
Could you help fix it? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, my bad.
Updated. It should be fine now.

# go test ./pkg/estimator/server/framework/plugins/resourcequota/... 
ok  	github.com/karmada-io/karmada/pkg/estimator/server/framework/plugins/resourcequota

@seanlaii
Copy link
Contributor

/assign

@RainbowMango RainbowMango force-pushed the pr_optimize_estimator_grpc branch from a975f2e to 71d335a Compare November 22, 2025 03:01
@seanlaii
Copy link
Contributor

seanlaii commented Nov 22, 2025

/lgtm
Thanks!

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2025
@RainbowMango RainbowMango added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 22, 2025
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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 merged commit c2609e5 into karmada-io:master Nov 22, 2025
24 checks passed
@RainbowMango RainbowMango deleted the pr_optimize_estimator_grpc branch November 22, 2025 03:58
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants