Skip to content

Commit c5d91e0

Browse files
authored
fix: reduce the places where users have to register for using custom plugins (#332)
1 parent ea14a28 commit c5d91e0

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

simulator/docs/custom-plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ by passing a default KubeSchedulerConfiguration file via the environment variabl
1919

2020
### Example
2121

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

2424
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.
2525
And we can configure it via `NodeNumberArgs`.

simulator/scheduler/config/plugin.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@ import (
77
"k8s.io/kubernetes/pkg/scheduler/framework/runtime"
88
)
99

10-
var (
11-
outOfTreeRegistries = runtime.Registry{
12-
// TODO(user): add your plugins registries here.
13-
}
14-
15-
registeredOutOfTreeMultiPointName = []string{}
16-
)
10+
var outOfTreeRegistries = runtime.Registry{
11+
// TODO(user): add your plugins registries here.
12+
}
1713

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

4541
func OutOfTreeMultiPointPluginNames() []string {
42+
registeredOutOfTreeMultiPointName := make([]string, 0, len(outOfTreeRegistries))
43+
for k := range outOfTreeRegistries {
44+
registeredOutOfTreeMultiPointName = append(registeredOutOfTreeMultiPointName, k)
45+
}
4646
return registeredOutOfTreeMultiPointName
4747
}
4848

@@ -57,6 +57,5 @@ func OutOfTreeRegistries() runtime.Registry {
5757
func SetOutOfTreeRegistries(r runtime.Registry) {
5858
for k, v := range r {
5959
outOfTreeRegistries[k] = v
60-
registeredOutOfTreeMultiPointName = append(registeredOutOfTreeMultiPointName, k)
6160
}
6261
}

0 commit comments

Comments
 (0)