-
Notifications
You must be signed in to change notification settings - Fork 17
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
extracts out pool and stubs plugin functions #31
extracts out pool and stubs plugin functions #31
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.
notes
"k8s.io/kubernetes/pkg/scheduler/framework" | ||
frameworkruntime "k8s.io/kubernetes/pkg/scheduler/framework/runtime" | ||
|
||
"github.com/tetratelabs/wazero" | ||
) | ||
|
||
const PluginName = "wasm" |
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.
all logic in this file is the same, I only implemented the plugin interfaces, stubbed with TODO.
// guestPool manages guest to pod assignments in a scheduling or binding cycle. | ||
type guestPool[guest any] struct { | ||
// newGuest is a function to create a new guest. | ||
newGuest func(context.Context) (guest, error) |
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.
By extracting this function and making it a generic type, I was able to find a subtle bug in the test.
} | ||
|
||
uid := types.UID("test-uid") | ||
differentuid := types.UID("test-uid") |
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.
this was the bug in test which drove me a little bonkers until I saw it ;)
// pointer to the current request. | ||
type filterArgsKey struct{} | ||
type filterParamsKey struct{} |
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.
nit: renamed to params because functions have parameters not args (in Go and Wasm)
// into the pool. | ||
func (p *guestPool[guest]) unassignForScheduling() { | ||
assigned := p.assignedToSchedulingPod | ||
var zero guest |
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.
only weird thing for people not used to generics is you can't cast to nil (guest(nil)
), However the following has the same effect.
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.
Only one nit, other LGTM
Signed-off-by: Adrian Cole <adrian@tetrate.io>
85dea52
to
a2a2805
Compare
/lgtm thanks |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: codefromthecrypt, kerthcet 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 |
thanks for the review @kerthcet! |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This extracts the guest pool into its own type so that it can be unit tested without export helpers. Notably, this makes it a generic type which makes testing a lot easier. In the process, I found and fixed a test bug.
This also stubs all the host-side plugins in declaration order according to the framework interface. This helps me understand what we are implementing, and allows the IDE to find the upstream documentation vs guessing.
https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/framework/interface.go#L304-L506
Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
Does this PR introduce a user-facing change?
NONE
What are the benchmark results of this change?
N/A