Skip to content

Conversation

@zhifei92
Copy link
Contributor

@zhifei92 zhifei92 commented Jul 24, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

The current configuration is such that as long as an extender is configured, e.g., extender.predicateVerb: predicate, all pods will go through the extender, even if they don't contain resources managed by the extender. This is not desirable.

More seriously, if the extender's implementation has shortcomings — for example, if it treats a filter as failed when the pod does not contain resources it manages — then pods that should have been scheduled successfully may end up failing to be scheduled.

Which issue(s) this PR fixes:

Fixes #4481

Special notes for your reviewer:

Does this PR introduce a user-facing change?

- Added support for managedResources configuration in extender
  - Only the resources explicitly listed under managedResources will be sent to the extender.
  - This gives you more control over which resources the extender interacts with, reducing unnecessary data transmission and improving efficiency.

@volcano-sh-bot volcano-sh-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 24, 2025
@volcano-sh-bot volcano-sh-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 24, 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.

Summary of Changes

Hello @zhifei92, 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 scheduler's extender mechanism by allowing administrators to explicitly define which resources an extender manages. Previously, all pods were sent to an extender if one was configured, leading to inefficiencies and potential scheduling failures for pods not relevant to the extender. With this change, the scheduler will now intelligently consult an extender only for pods that request resources specifically managed by that extender, thereby streamlining the scheduling process and improving overall system stability.

Highlights

  • Configurable Managed Resources: I've introduced a new configuration parameter, extender.managedResources, which allows specifying a comma-separated list of resource names (e.g., nvidia.com/gpu) that a particular extender is responsible for. This enables fine-grained control over which resources an extender should care about.
  • Targeted Extender Invocation: The extender plugin now includes an IsInterested check. Before invoking any extender functions (predicate, prioritize, preemptable, reclaimable, or event handlers), it verifies if the task (pod) explicitly requests any of the resources configured in extender.managedResources. If no managedResources are specified, the extender behaves as before, processing all pods.
  • Improved Efficiency and Robustness: By only sending relevant pods to the extender, this change reduces unnecessary network calls and processing overhead. It also mitigates scenarios where an extender might incorrectly fail a scheduling decision for a pod that doesn't utilize its managed resources, addressing the core problem outlined in the PR description.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 or fill out our survey to provide feedback.

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

@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 a managedResources configuration for the extender plugin, allowing it to selectively process pods based on the resources they request. This is a great feature for improving efficiency and robustness. The implementation is well done, but I've provided a few suggestions to improve code quality and strongly recommend adding unit tests for the new logic to ensure its correctness.

Comment on lines +378 to +388
func (ep *extenderPlugin) IsInterested(task *api.TaskInfo) bool {
if ep.config.managedResources.Len() == 0 {
return true
}
if ep.hasManagedResources(task.Pod.Spec.Containers) {
return true
}
if ep.hasManagedResources(task.Pod.Spec.InitContainers) {
return true
}
return false
}

Choose a reason for hiding this comment

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

high

The new IsInterested function and its helper hasManagedResources introduce critical logic for the extender plugin, but they are not covered by unit tests. This makes it hard to verify correctness and prevent future regressions.

Copy link
Member

Choose a reason for hiding this comment

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

@zhifei92 Please add UTs

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

Comment on lines +382 to +387
if ep.hasManagedResources(task.Pod.Spec.Containers) {
return true
}
if ep.hasManagedResources(task.Pod.Spec.InitContainers) {
return true
}
return false

Choose a reason for hiding this comment

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

medium

The boolean logic here can be simplified to be more concise and idiomatic Go.

return ep.hasManagedResources(task.Pod.Spec.Containers) ||
ep.hasManagedResources(task.Pod.Spec.InitContainers)

Comment on lines 394 to 405
for resourceName := range container.Resources.Requests {
if ep.config.managedResources.Has(string(resourceName)) {
return true
}
}
for resourceName := range container.Resources.Limits {
if ep.config.managedResources.Has(string(resourceName)) {
return true
}
}

Choose a reason for hiding this comment

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

medium

The loops for checking container.Resources.Requests and container.Resources.Limits are identical. You can reduce this code duplication by iterating over a slice containing both resource lists.

for _, resourceList := range []corev1.ResourceList{container.Resources.Requests, container.Resources.Limits} {
for resourceName := range resourceList {
if ep.config.managedResources.Has(string(resourceName)) {
return true
}
}
}

Comment on lines +419 to +422
if !ep.IsInterested(event.Task) {
return

Choose a reason for hiding this comment

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

medium

Consider adding a comment to explain why the function returns if the task is not interested.

// If the task is not interested, skip the event handler.
if !ep.IsInterested(event.Task) {
return
}

Copy link
Member

@JesseStutler JesseStutler left a comment

Choose a reason for hiding this comment

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

Please also use git commit -s to sign your commit thanks

Comment on lines +378 to +388
func (ep *extenderPlugin) IsInterested(task *api.TaskInfo) bool {
if ep.config.managedResources.Len() == 0 {
return true
}
if ep.hasManagedResources(task.Pod.Spec.Containers) {
return true
}
if ep.hasManagedResources(task.Pod.Spec.InitContainers) {
return true
}
return false
}
Copy link
Member

Choose a reason for hiding this comment

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

@zhifei92 Please add UTs

@Monokaix
Copy link
Member

Please also add ut and signoff your commit.

@zhifei92 zhifei92 force-pushed the interested-resources branch from 6aeb6c1 to 990c118 Compare July 25, 2025 09:59
@volcano-sh-bot volcano-sh-bot 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 Jul 25, 2025
@zhifei92
Copy link
Contributor Author

Please also add ut and signoff your commit.

done

@Monokaix
Copy link
Member

/approve

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Monokaix

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

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 26, 2025
@zhifei92
Copy link
Contributor Author

@Monokaix @JesseStutler One more lgtm is needed, thank you!

Copy link
Member

@JesseStutler JesseStutler left a comment

Choose a reason for hiding this comment

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

/lgtm
Thanks!

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 28, 2025
@volcano-sh-bot volcano-sh-bot merged commit db7f25b into volcano-sh:master Jul 28, 2025
19 checks passed
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.

Support configuring resources managed by the extender

4 participants