-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathsession_plugins.go
793 lines (707 loc) · 19.2 KB
/
session_plugins.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package framework
import (
k8sframework "k8s.io/kubernetes/pkg/scheduler/framework"
"volcano.sh/apis/pkg/apis/scheduling"
"volcano.sh/volcano/pkg/controllers/job/helpers"
"volcano.sh/volcano/pkg/scheduler/api"
)
// AddJobOrderFn add job order function
func (ssn *Session) AddJobOrderFn(name string, cf api.CompareFn) {
ssn.jobOrderFns[name] = cf
}
// AddQueueOrderFn add queue order function
func (ssn *Session) AddQueueOrderFn(name string, qf api.CompareFn) {
ssn.queueOrderFns[name] = qf
}
// AddClusterOrderFn add queue order function
func (ssn *Session) AddClusterOrderFn(name string, qf api.CompareFn) {
ssn.clusterOrderFns[name] = qf
}
// AddTaskOrderFn add task order function
func (ssn *Session) AddTaskOrderFn(name string, cf api.CompareFn) {
ssn.taskOrderFns[name] = cf
}
// AddNamespaceOrderFn add namespace order function
func (ssn *Session) AddNamespaceOrderFn(name string, cf api.CompareFn) {
ssn.namespaceOrderFns[name] = cf
}
// AddPreemptableFn add preemptable function
func (ssn *Session) AddPreemptableFn(name string, cf api.EvictableFn) {
ssn.preemptableFns[name] = cf
}
// AddReclaimableFn add Reclaimable function
func (ssn *Session) AddReclaimableFn(name string, rf api.EvictableFn) {
ssn.reclaimableFns[name] = rf
}
// AddJobReadyFn add JobReady function
func (ssn *Session) AddJobReadyFn(name string, vf api.ValidateFn) {
ssn.jobReadyFns[name] = vf
}
// AddJobPipelinedFn add pipelined function
func (ssn *Session) AddJobPipelinedFn(name string, vf api.VoteFn) {
ssn.jobPipelinedFns[name] = vf
}
// AddPredicateFn add Predicate function
func (ssn *Session) AddPredicateFn(name string, pf api.PredicateFn) {
ssn.predicateFns[name] = pf
}
// AddPredicateFn add Predicate function
func (ssn *Session) AddPrePredicateFn(name string, pf api.PrePredicateFn) {
ssn.prePredicateFns[name] = pf
}
// AddBestNodeFn add BestNode function
func (ssn *Session) AddBestNodeFn(name string, pf api.BestNodeFn) {
ssn.bestNodeFns[name] = pf
}
// AddNodeOrderFn add Node order function
func (ssn *Session) AddNodeOrderFn(name string, pf api.NodeOrderFn) {
ssn.nodeOrderFns[name] = pf
}
// AddBatchNodeOrderFn add Batch Node order function
func (ssn *Session) AddBatchNodeOrderFn(name string, pf api.BatchNodeOrderFn) {
ssn.batchNodeOrderFns[name] = pf
}
// AddNodeMapFn add Node map function
func (ssn *Session) AddNodeMapFn(name string, pf api.NodeMapFn) {
ssn.nodeMapFns[name] = pf
}
// AddNodeReduceFn add Node reduce function
func (ssn *Session) AddNodeReduceFn(name string, pf api.NodeReduceFn) {
ssn.nodeReduceFns[name] = pf
}
// AddOverusedFn add overused function
func (ssn *Session) AddOverusedFn(name string, fn api.ValidateFn) {
ssn.overusedFns[name] = fn
}
// AddAllocatableFn add allocatable function
func (ssn *Session) AddAllocatableFn(name string, fn api.AllocatableFn) {
ssn.allocatableFns[name] = fn
}
// AddJobValidFn add jobvalid function
func (ssn *Session) AddJobValidFn(name string, fn api.ValidateExFn) {
ssn.jobValidFns[name] = fn
}
// AddJobEnqueueableFn add jobenqueueable function
func (ssn *Session) AddJobEnqueueableFn(name string, fn api.VoteFn) {
ssn.jobEnqueueableFns[name] = fn
}
// AddJobEnqueuedFn add jobEnqueued function
func (ssn *Session) AddJobEnqueuedFn(name string, fn api.JobEnqueuedFn) {
ssn.jobEnqueuedFns[name] = fn
}
// AddTargetJobFn add targetjob function
func (ssn *Session) AddTargetJobFn(name string, fn api.TargetJobFn) {
ssn.targetJobFns[name] = fn
}
// AddReservedNodesFn add reservedNodesFn function
func (ssn *Session) AddReservedNodesFn(name string, fn api.ReservedNodesFn) {
ssn.reservedNodesFns[name] = fn
}
// AddVictimTasksFns add victimTasksFns function
func (ssn *Session) AddVictimTasksFns(name string, fns []api.VictimTasksFn) {
ssn.victimTasksFns[name] = fns
}
// AddJobStarvingFns add jobStarvingFns function
func (ssn *Session) AddJobStarvingFns(name string, fn api.ValidateFn) {
ssn.jobStarvingFns[name] = fn
}
// Reclaimable invoke reclaimable function of the plugins
func (ssn *Session) Reclaimable(reclaimer *api.TaskInfo, reclaimees []*api.TaskInfo) []*api.TaskInfo {
var victims []*api.TaskInfo
var init bool
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledReclaimable) {
continue
}
rf, found := ssn.reclaimableFns[plugin.Name]
if !found {
continue
}
candidates, abstain := rf(reclaimer, reclaimees)
if abstain == 0 {
continue
}
if len(candidates) == 0 {
victims = nil
break
}
if !init {
victims = candidates
init = true
} else {
var intersection []*api.TaskInfo
// Get intersection of victims and candidates.
for _, v := range victims {
for _, c := range candidates {
if v.UID == c.UID {
intersection = append(intersection, v)
}
}
}
// Update victims to intersection
victims = intersection
}
}
// Plugins in this tier made decision if victims is not nil
if victims != nil {
return victims
}
}
return victims
}
// Preemptable invoke preemptable function of the plugins
func (ssn *Session) Preemptable(preemptor *api.TaskInfo, preemptees []*api.TaskInfo) []*api.TaskInfo {
var victims []*api.TaskInfo
var init bool
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledPreemptable) {
continue
}
pf, found := ssn.preemptableFns[plugin.Name]
if !found {
continue
}
candidates, abstain := pf(preemptor, preemptees)
if abstain == 0 {
continue
}
// intersection will be nil if length is 0, don't need to do any more check
if len(candidates) == 0 {
victims = nil
break
}
if !init {
victims = candidates
init = true
} else {
var intersection []*api.TaskInfo
// Get intersection of victims and candidates.
for _, v := range victims {
for _, c := range candidates {
if v.UID == c.UID {
intersection = append(intersection, v)
}
}
}
// Update victims to intersection
victims = intersection
}
}
// Plugins in this tier made decision if victims is not nil
if victims != nil {
return victims
}
}
return victims
}
// Overused invoke overused function of the plugins
func (ssn *Session) Overused(queue *api.QueueInfo) bool {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledOverused) {
continue
}
of, found := ssn.overusedFns[plugin.Name]
if !found {
continue
}
if of(queue) {
return true
}
}
}
return false
}
// Allocatable invoke allocatable function of the plugins
func (ssn *Session) Allocatable(queue *api.QueueInfo, candidate *api.TaskInfo) bool {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledAllocatable) {
continue
}
af, found := ssn.allocatableFns[plugin.Name]
if !found {
continue
}
if !af(queue, candidate) {
return false
}
}
}
return true
}
// JobReady invoke jobready function of the plugins
func (ssn *Session) JobReady(obj interface{}) bool {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledJobReady) {
continue
}
jrf, found := ssn.jobReadyFns[plugin.Name]
if !found {
continue
}
if !jrf(obj) {
return false
}
}
}
return true
}
// JobPipelined invoke pipelined function of the plugins
// Check if job has get enough resource to run
func (ssn *Session) JobPipelined(obj interface{}) bool {
var hasFound bool
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledJobPipelined) {
continue
}
jrf, found := ssn.jobPipelinedFns[plugin.Name]
if !found {
continue
}
res := jrf(obj)
if res < 0 {
return false
}
if res > 0 {
hasFound = true
}
}
// if plugin exists that votes permit, meanwhile other plugin votes abstention,
// permit job to be pipelined, do not check next tier
if hasFound {
return true
}
}
return true
}
// JobStarving invoke jobStarving function of the plugins
// Check if job still need more resource
func (ssn *Session) JobStarving(obj interface{}) bool {
var hasFound bool
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledJobStarving) {
continue
}
jrf, found := ssn.jobStarvingFns[plugin.Name]
if !found {
continue
}
hasFound = true
if !jrf(obj) {
return false
}
}
// this tier registered function
if hasFound {
return true
}
}
return false
}
// JobValid invoke jobvalid function of the plugins
func (ssn *Session) JobValid(obj interface{}) *api.ValidateResult {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
jrf, found := ssn.jobValidFns[plugin.Name]
if !found {
continue
}
if vr := jrf(obj); vr != nil && !vr.Pass {
return vr
}
}
}
return nil
}
// JobEnqueueable invoke jobEnqueueableFns function of the plugins
func (ssn *Session) JobEnqueueable(obj interface{}) bool {
var hasFound bool
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledJobEnqueued) {
continue
}
fn, found := ssn.jobEnqueueableFns[plugin.Name]
if !found {
continue
}
res := fn(obj)
if res < 0 {
return false
}
if res > 0 {
hasFound = true
}
}
// if plugin exists that votes permit, meanwhile other plugin votes abstention,
// permit job to be enqueueable, do not check next tier
if hasFound {
return true
}
}
return true
}
// JobEnqueued invoke jobEnqueuedFns function of the plugins
func (ssn *Session) JobEnqueued(obj interface{}) {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledJobEnqueued) {
continue
}
fn, found := ssn.jobEnqueuedFns[plugin.Name]
if !found {
continue
}
fn(obj)
}
}
}
// TargetJob invoke targetJobFns function of the plugins
func (ssn *Session) TargetJob(jobs []*api.JobInfo) *api.JobInfo {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledTargetJob) {
continue
}
fn, found := ssn.targetJobFns[plugin.Name]
if !found {
continue
}
return fn(jobs)
}
}
return nil
}
// VictimTasks returns the victims selected
func (ssn *Session) VictimTasks(tasks []*api.TaskInfo) map[*api.TaskInfo]bool {
// different filters may add the same task to victims, so use a map to remove duplicate tasks.
victimSet := make(map[*api.TaskInfo]bool)
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledVictim) {
continue
}
fns, found := ssn.victimTasksFns[plugin.Name]
if !found {
continue
}
for _, fn := range fns {
victimTasks := fn(tasks)
for _, victim := range victimTasks {
victimSet[victim] = true
}
}
}
if len(victimSet) > 0 {
return victimSet
}
}
return victimSet
}
// ReservedNodes invoke ReservedNodes function of the plugins
func (ssn *Session) ReservedNodes() {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledReservedNodes) {
continue
}
fn, found := ssn.reservedNodesFns[plugin.Name]
if !found {
continue
}
fn()
}
}
}
// JobOrderFn invoke joborder function of the plugins
func (ssn *Session) JobOrderFn(l, r interface{}) bool {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledJobOrder) {
continue
}
jof, found := ssn.jobOrderFns[plugin.Name]
if !found {
continue
}
if j := jof(l, r); j != 0 {
return j < 0
}
}
}
// If no job order funcs, order job by CreationTimestamp first, then by UID.
lv := l.(*api.JobInfo)
rv := r.(*api.JobInfo)
if lv.CreationTimestamp.Equal(&rv.CreationTimestamp) {
return lv.UID < rv.UID
}
return lv.CreationTimestamp.Before(&rv.CreationTimestamp)
}
// NamespaceOrderFn invoke namespaceorder function of the plugins
func (ssn *Session) NamespaceOrderFn(l, r interface{}) bool {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledNamespaceOrder) {
continue
}
nof, found := ssn.namespaceOrderFns[plugin.Name]
if !found {
continue
}
if j := nof(l, r); j != 0 {
return j < 0
}
}
}
// TODO(lminzhw): if all NamespaceOrderFn treat these two namespace as the same,
// we should make the job order have its affect among namespaces.
// or just schedule namespace one by one
lv := l.(api.NamespaceName)
rv := r.(api.NamespaceName)
return lv < rv
}
// ClusterOrderFn invoke ClusterOrderFn function of the plugins
func (ssn *Session) ClusterOrderFn(l, r interface{}) bool {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledClusterOrder) {
continue
}
cof, found := ssn.clusterOrderFns[plugin.Name]
if !found {
continue
}
if j := cof(l, r); j != 0 {
return j < 0
}
}
}
// If no cluster order funcs, order cluster by ClusterID
lv := l.(*scheduling.Cluster)
rv := r.(*scheduling.Cluster)
return lv.Name < rv.Name
}
// QueueOrderFn invoke queueorder function of the plugins
func (ssn *Session) QueueOrderFn(l, r interface{}) bool {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledQueueOrder) {
continue
}
qof, found := ssn.queueOrderFns[plugin.Name]
if !found {
continue
}
if j := qof(l, r); j != 0 {
return j < 0
}
}
}
// If no queue order funcs, order queue by CreationTimestamp first, then by UID.
lv := l.(*api.QueueInfo)
rv := r.(*api.QueueInfo)
if lv.Queue.CreationTimestamp.Equal(&rv.Queue.CreationTimestamp) {
return lv.UID < rv.UID
}
return lv.Queue.CreationTimestamp.Before(&rv.Queue.CreationTimestamp)
}
// TaskCompareFns invoke taskorder function of the plugins
func (ssn *Session) TaskCompareFns(l, r interface{}) int {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledTaskOrder) {
continue
}
tof, found := ssn.taskOrderFns[plugin.Name]
if !found {
continue
}
if j := tof(l, r); j != 0 {
return j
}
}
}
return 0
}
// TaskOrderFn invoke taskorder function of the plugins
func (ssn *Session) TaskOrderFn(l, r interface{}) bool {
if res := ssn.TaskCompareFns(l, r); res != 0 {
return res < 0
}
// If no task order funcs, order task by default func.
lv := l.(*api.TaskInfo)
rv := r.(*api.TaskInfo)
return helpers.CompareTask(lv, rv)
}
// PredicateFn invoke predicate function of the plugins
func (ssn *Session) PredicateFn(task *api.TaskInfo, node *api.NodeInfo) error {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledPredicate) {
continue
}
pfn, found := ssn.predicateFns[plugin.Name]
if !found {
continue
}
err := pfn(task, node)
if err != nil {
return err
}
}
}
return nil
}
// PrePredicateFn invoke predicate function of the plugins
func (ssn *Session) PrePredicateFn(task *api.TaskInfo) error {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
// we use same option as predicates for they are
if !isEnabled(plugin.EnabledPredicate) {
continue
}
pfn, found := ssn.prePredicateFns[plugin.Name]
if !found {
continue
}
err := pfn(task)
if err != nil {
return err
}
}
}
return nil
}
// BestNodeFn invoke bestNode function of the plugins
func (ssn *Session) BestNodeFn(task *api.TaskInfo, nodeScores map[float64][]*api.NodeInfo) *api.NodeInfo {
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledBestNode) {
continue
}
pfn, found := ssn.bestNodeFns[plugin.Name]
if !found {
continue
}
// Only the first plugin that enables and realizes bestNodeFn is allowed to choose best node for task
if bestNode := pfn(task, nodeScores); bestNode != nil {
return bestNode
}
}
}
return nil
}
// NodeOrderFn invoke node order function of the plugins
func (ssn *Session) NodeOrderFn(task *api.TaskInfo, node *api.NodeInfo) (float64, error) {
priorityScore := 0.0
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledNodeOrder) {
continue
}
pfn, found := ssn.nodeOrderFns[plugin.Name]
if !found {
continue
}
score, err := pfn(task, node)
if err != nil {
return 0, err
}
priorityScore += score
}
}
return priorityScore, nil
}
// BatchNodeOrderFn invoke node order function of the plugins
func (ssn *Session) BatchNodeOrderFn(task *api.TaskInfo, nodes []*api.NodeInfo) (map[string]float64, error) {
priorityScore := make(map[string]float64, len(nodes))
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledNodeOrder) {
continue
}
pfn, found := ssn.batchNodeOrderFns[plugin.Name]
if !found {
continue
}
score, err := pfn(task, nodes)
if err != nil {
return nil, err
}
for nodeName, score := range score {
priorityScore[nodeName] += score
}
}
}
return priorityScore, nil
}
func isEnabled(enabled *bool) bool {
return enabled != nil && *enabled
}
// NodeOrderMapFn invoke node order function of the plugins
func (ssn *Session) NodeOrderMapFn(task *api.TaskInfo, node *api.NodeInfo) (map[string]float64, float64, error) {
nodeScoreMap := map[string]float64{}
var priorityScore float64
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledNodeOrder) {
continue
}
if pfn, found := ssn.nodeOrderFns[plugin.Name]; found {
score, err := pfn(task, node)
if err != nil {
return nodeScoreMap, priorityScore, err
}
priorityScore += score
}
if pfn, found := ssn.nodeMapFns[plugin.Name]; found {
score, err := pfn(task, node)
if err != nil {
return nodeScoreMap, priorityScore, err
}
nodeScoreMap[plugin.Name] = score
}
}
}
return nodeScoreMap, priorityScore, nil
}
// NodeOrderReduceFn invoke node order function of the plugins
func (ssn *Session) NodeOrderReduceFn(task *api.TaskInfo, pluginNodeScoreMap map[string]k8sframework.NodeScoreList) (map[string]float64, error) {
nodeScoreMap := map[string]float64{}
for _, tier := range ssn.Tiers {
for _, plugin := range tier.Plugins {
if !isEnabled(plugin.EnabledNodeOrder) {
continue
}
pfn, found := ssn.nodeReduceFns[plugin.Name]
if !found {
continue
}
if err := pfn(task, pluginNodeScoreMap[plugin.Name]); err != nil {
return nodeScoreMap, err
}
for _, hp := range pluginNodeScoreMap[plugin.Name] {
nodeScoreMap[hp.Name] += float64(hp.Score)
}
}
}
return nodeScoreMap, nil
}