-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support configuring resources managed by the extender #4482
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
Support configuring resources managed by the extender #4482
Conversation
There was a problem hiding this 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
IsInterestedcheck. 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 inextender.managedResources. If nomanagedResourcesare 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
-
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. ↩
There was a problem hiding this 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.
| 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 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhifei92 Please add UTs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| if ep.hasManagedResources(task.Pod.Spec.Containers) { | ||
| return true | ||
| } | ||
| if ep.hasManagedResources(task.Pod.Spec.InitContainers) { | ||
| return true | ||
| } | ||
| return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
}
}
}| if !ep.IsInterested(event.Task) { | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JesseStutler
left a comment
There was a problem hiding this 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
| 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 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhifei92 Please add UTs
|
Please also add ut and signoff your commit. |
Signed-off-by: zhangzhifei16 <[email protected]>
6aeb6c1 to
990c118
Compare
done |
|
/approve |
|
[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 |
|
@Monokaix @JesseStutler One more lgtm is needed, thank you! |
JesseStutler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Thanks!
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
extenderis configured, e.g.,extender.predicateVerb: predicate, all pods will go through theextender, even if they don't contain resources managed by theextender. 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?