Skip to content

Commit

Permalink
fix: reduce the places where users have to register for using custom …
Browse files Browse the repository at this point in the history
…plugins (#332)
  • Loading branch information
sanposhiho committed Mar 29, 2024
1 parent ea14a28 commit c5d91e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion simulator/docs/custom-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ by passing a default KubeSchedulerConfiguration file via the environment variabl

### Example

We will explain the case where you want to add [nodenumber](../sample/nodenumber/plugin.go) plugin as example.
We will explain the case where you want to add [nodenumber](./sample/nodenumber/plugin.go) plugin as example.

The nodenumber plugin is an example plugin that favors nodes that have the number suffix which is the same as the number suffix of the pod name.
And we can configure it via `NodeNumberArgs`.
Expand Down
15 changes: 7 additions & 8 deletions simulator/scheduler/config/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import (
"k8s.io/kubernetes/pkg/scheduler/framework/runtime"
)

var (
outOfTreeRegistries = runtime.Registry{
// TODO(user): add your plugins registries here.
}

registeredOutOfTreeMultiPointName = []string{}
)
var outOfTreeRegistries = runtime.Registry{
// TODO(user): add your plugins registries here.
}

// RegisteredMultiPointPluginNames returns all registered multipoint plugin names.
// in-tree plugins and your original plugins listed in outOfTreeRegistries above.
Expand Down Expand Up @@ -43,6 +39,10 @@ func InTreeMultiPointPluginSet() (configv1.PluginSet, error) {
}

func OutOfTreeMultiPointPluginNames() []string {
registeredOutOfTreeMultiPointName := make([]string, 0, len(outOfTreeRegistries))
for k := range outOfTreeRegistries {
registeredOutOfTreeMultiPointName = append(registeredOutOfTreeMultiPointName, k)
}
return registeredOutOfTreeMultiPointName
}

Expand All @@ -57,6 +57,5 @@ func OutOfTreeRegistries() runtime.Registry {
func SetOutOfTreeRegistries(r runtime.Registry) {
for k, v := range r {
outOfTreeRegistries[k] = v
registeredOutOfTreeMultiPointName = append(registeredOutOfTreeMultiPointName, k)
}
}

0 comments on commit c5d91e0

Please sign in to comment.