@@ -32,6 +32,9 @@ import (
32
32
)
33
33
34
34
const (
35
+ // PluginName indicates name of volcano scheduler plugin.
36
+ PluginName = "nodeorder"
37
+
35
38
// NodeAffinityWeight is the key for providing Node Affinity Priority Weight in YAML
36
39
NodeAffinityWeight = "nodeaffinity.weight"
37
40
// PodAffinityWeight is the key for providing Pod Affinity Priority Weight in YAML
@@ -47,43 +50,13 @@ type nodeOrderPlugin struct {
47
50
pluginArguments framework.Arguments
48
51
}
49
52
50
- func getInterPodAffinityScore (name string , interPodAffinityScore schedulerapi.HostPriorityList ) int {
51
- for _ , hostPriority := range interPodAffinityScore {
52
- if hostPriority .Host == name {
53
- return hostPriority .Score
54
- }
55
- }
56
- return 0
57
- }
58
-
59
- type cachedNodeInfo struct {
60
- session * framework.Session
61
- }
62
-
63
- func (c * cachedNodeInfo ) GetNodeInfo (name string ) (* v1.Node , error ) {
64
- node , found := c .session .Nodes [name ]
65
- if ! found {
66
- for _ , cacheNode := range c .session .Nodes {
67
- pods := cacheNode .Pods ()
68
- for _ , pod := range pods {
69
- if pod .Spec .NodeName == "" {
70
- return cacheNode .Node , nil
71
- }
72
- }
73
- }
74
- return nil , fmt .Errorf ("failed to find node <%s>" , name )
75
- }
76
-
77
- return node .Node , nil
78
- }
79
-
80
53
//New function returns prioritizePlugin object
81
54
func New (aruguments framework.Arguments ) framework.Plugin {
82
55
return & nodeOrderPlugin {pluginArguments : aruguments }
83
56
}
84
57
85
58
func (pp * nodeOrderPlugin ) Name () string {
86
- return "nodeorder"
59
+ return PluginName
87
60
}
88
61
89
62
type priorityWeight struct {
@@ -249,3 +222,24 @@ func (pp *nodeOrderPlugin) OnSessionOpen(ssn *framework.Session) {
249
222
250
223
func (pp * nodeOrderPlugin ) OnSessionClose (ssn * framework.Session ) {
251
224
}
225
+
226
+ type cachedNodeInfo struct {
227
+ session * framework.Session
228
+ }
229
+
230
+ func (c * cachedNodeInfo ) GetNodeInfo (name string ) (* v1.Node , error ) {
231
+ node , found := c .session .Nodes [name ]
232
+ if ! found {
233
+ for _ , cacheNode := range c .session .Nodes {
234
+ pods := cacheNode .Pods ()
235
+ for _ , pod := range pods {
236
+ if pod .Spec .NodeName == "" {
237
+ return cacheNode .Node , nil
238
+ }
239
+ }
240
+ }
241
+ return nil , fmt .Errorf ("failed to find node <%s>" , name )
242
+ }
243
+
244
+ return node .Node , nil
245
+ }
0 commit comments