-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Move RunNormalizeScorePlugins and ApplyScoreWeights into RunScorePlugins; Also add unit tests for RunScorePlugins. #81614
Conversation
Hi @liu-cong. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
/ok-to-test |
/test pull-kubernetes-e2e-gce-device-plugin-gpu |
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
6666579
to
4b31da7
Compare
func (f *framework) RunNormalizeScorePlugins(pc *PluginContext, pod *v1.Pod, scores PluginToNodeScores) *Status { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
errCh := schedutil.NewErrorChannel() | ||
// Run NormalizeScore method for each ScoreWithNormalizePlugin in parallel. |
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.
why not keep the functions and just make them local (normalizeScores and applyScoreWeights)?
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.
I just found the 3 steps are very similar (parallel execution and receive error) and it looks good to me to put them in the same function (saves a few lines of code). But no particular reason really.
If you like the separately, I can change it.
…ins; Also add unit tests for RunScorePlugins.
4b31da7
to
e50a24d
Compare
/lgtm Thanks Cong |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahg-g, liu-cong 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 |
/test pull-kubernetes-kubemark-e2e-gce-big |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Normalizing scores and applying score weights are details of the Score phase in the framework that the caller (generic_scheduler) doesn't need to care about. With this change, RunScorePlugins method now also runs the normalize and apply score weights logic internally. The change has the following benefits:
Hides details from outside makes the code easy to use and less error prone
Previously caller had to call 3 methods in the right order.
Simplifies the code and unit tests.
Previously we had to check that score results exists for each plugin in the fear that the score result map could get updated in between the 3 methods. Now the map is an internal data structure and the caller cannot intervene with it during Score.
This is a follow up to a previous comment:
One thing we can do to avoid those extra checks and simplify the code in generic_scheduler is to make both RunNormalizeScorePlugins and ApplyWeights private functions of the framework and call them directly at the end of RunScorePlugins.
@hex108, @ahg-g
Which issue(s) this PR fixes:
Contributes to #80272
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: