Skip to content
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

fix: repear scheduler_perf to run correctly #116

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Conversation

sanposhiho
Copy link
Member

@sanposhiho sanposhiho commented Aug 23, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

1. Fix a bug with NormalizedScore

Currently, when the guest doesn't implement NormalizedScore, the wasm plugin (scheduler side) errors out, which makes scheduler_perf fail right now.
https://github.com/kubernetes-sigs/kube-scheduler-wasm-extension/blob/main/scheduler/plugin/plugin.go#L341-L343

We should restore the node list when the guest returns nil.

2. Create a wasm for scheduler_perf

We're using examples/nodenumber in scheduler_perf, but examples/nodenumber uses many additional features (klog and event recorder) which creates additional overhead.
With scheduler_perf, we just want to compare the performance difference between (default scheduler,) wasm plugin and extender under the same condition (running Score() or /priorities which only has almost the same logic inside).
This PR creates the simplest nodenumber wasm plugin to be used in scheduler_perf for this purpose.

We can add more wasm plugins per test case later. (e.g., the one that uses logging a lot, etc)

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


What are the benchmark results of this change?


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 23, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 23, 2024
@sanposhiho sanposhiho force-pushed the scheduler-perf-run branch 3 times, most recently from 7c7b010 to f90917a Compare August 23, 2024 14:26
@sanposhiho
Copy link
Member Author

/cc @Gekko0114 @utam0k

@@ -220,6 +220,11 @@ func (g *guest) normalizeScore(ctx context.Context) (framework.NodeScoreList, *f
statusCode := int32(callStack[0])
statusReason := paramsFromContext(ctx).resultStatusReason
normalizedScoreList := paramsFromContext(ctx).resultNormalizedScoreList
if len(normalizedScoreList) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

nit: What if the length of normalizedScoreList is not equal to the length of nodeScoreList ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We return the error:
https://github.com/kubernetes-sigs/kube-scheduler-wasm-extension/blob/main/scheduler/plugin/plugin.go#L341-L343

We shouldn't restore the score list in that case because if the length is unmatched, that's the bug in the guest. (The guest filled in an invalid node score list)
We should error out, rather than hiding the bug.

And, what we're trying to do here is not hide the bug. When the guest doesn't implement the normalizescore, we just return without doing anything, which results in an empty resultNormalizedScoreList, and hence fail.

https://github.com/kubernetes-sigs/kube-scheduler-wasm-extension/blob/main/guest/scoreextensions/scoreextensions.go#L64-L68

Copy link
Member

Choose a reason for hiding this comment

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

what we're trying to do here is not hide the bug. When the guest doesn't implement the normalizescore, we just return without doing anything, which results in an empty resultNormalizedScoreList, and hence fail.

Make sense. Thank you so much for your explanation!

Copy link
Member

@Gekko0114 Gekko0114 left a comment

Choose a reason for hiding this comment

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

Overall looks good, thanks so much for fixing this (I remembered that I had implemented scoreExtensions for wasm plugin)
Left one comment.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Gekko0114, sanposhiho

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

@Gekko0114
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 26, 2024
@k8s-ci-robot k8s-ci-robot merged commit 478db5b into main Aug 26, 2024
6 checks passed
@k8s-ci-robot k8s-ci-robot deleted the scheduler-perf-run branch August 26, 2024 11:52
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", 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.

3 participants