-
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
Implement EnqueueExtensions #55
Implement EnqueueExtensions #55
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: codefromthecrypt 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 |
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
|
||
// Constants for GVKs. | ||
const ( | ||
Pod GVK = iota |
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.
after I moved the other types to another package, I was able to mostly copy/paste this. I didn't make a RATIONALE entry about coercion from string to uint32, but on approval I will. The main thing is that this makes encoding far simpler. We should add documentation for framework.GVK
that custom values are not supported: it is only controlled by kubernetes scheduler framework.
guest/enqueue/clusterevent.go
Outdated
import "sigs.k8s.io/kube-scheduler-wasm-extension/guest/api" | ||
|
||
// minEncodedClusterEvent is the size in bytes to encode api.ClusterEvent with | ||
// 32-bit little endian gvk, ActionType, NUL-terminated Label, |
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.
note: later we need to make an ABI doc with details like this consolidated, but as everything is in-flux not doing this right now and instead relying on tests.
// enqueue is only exported to the host. | ||
// | ||
//export enqueue | ||
func _enqueue() { |
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.
currently enqueue returns nothing, not a framework status. We can change it if this does. I chose the name enqueue as it is a lot simpler than EventsToRegister
. However, if there is another function for enqueue, let me know and I can change it...
|
||
func main() { | ||
if len(os.Args) == 2 { | ||
switch os.Args[1] { |
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 made this switch on args as I really couldn't figure out how to export a mutable global in tinygo target=wasi. cc @deadprogram in case you know? This is fine anyway..
} | ||
|
||
// EventsToRegister implements the same method as documented on framework.EnqueueExtensions. | ||
func (pl *wasmPlugin) EventsToRegister() (clusterEvents []framework.ClusterEvent) { |
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.
to make things stop explosion, we add a default impl for enqueue extensions with the same behavior as if it wasn't if the guest doesn't support them
d256c5a
to
430dc59
Compare
ok I cleaned up the PR so that it is ready to merge if ok (backfilled test coverage and notes). After this, we can add guest config (e.g. plugin to read yaml or otherwise) and PreScore, so we can implement a realistic, configurable plugin like nodenumber. |
430dc59
to
e3ec274
Compare
e3ec274
to
df0f66e
Compare
ok all good. bench should have become a little worse on noop, due to extra hook. Things look correct now. |
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.
Thanks for the effort.
Looks great overall!
Signed-off-by: Adrian Cole <adrian@tetrate.io>
df0f66e
to
bc43ae9
Compare
@sanposhiho PTAL I think I got everything (pre-squashed) |
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.
Thanks. Only one nit, lgtm other things.
/lgtm
/hold
Feel free to /unhold
by yourself to get this merged after the fix, please.
ActionType ActionType | ||
} | ||
|
||
// ^-- Note: This does not include Label. |
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.
👍
Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
New changes are detected. LGTM label has been removed. |
thanks for the catch @sanposhiho! |
/unhold |
tomorrow I'll work on pre-score and hopefully config. after that, we should be able to port a basic plugin. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This implements
framework.EnqueueExtensions
which is needed for common sample plugins, such as nodenumberThis also reduces namespace conflicts by moving the guest code that is related to protos into its own package. Notably there's a conflict on the framework symbol
Node
and the proto type.Which issue(s) this PR fixes:
N/A
Special notes for your reviewer:
Does this PR introduce a user-facing change?
NONE
What are the benchmark results of this change?