@@ -3,6 +3,7 @@ package picker
3
3
import (
4
4
"fmt"
5
5
6
+ "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/plugins"
6
7
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
7
8
logutil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/logging"
8
9
)
@@ -11,15 +12,15 @@ import (
11
12
// candidates.
12
13
type MaxScorePicker struct {}
13
14
14
- // var _ types .Picker = &MaxScorePicker{}
15
+ var _ plugins .Picker = & MaxScorePicker {}
15
16
16
17
// Name returns the name of the picker.
17
18
func (msp * MaxScorePicker ) Name () string {
18
19
return "max-score"
19
20
}
20
21
21
22
// Pick selects the pod with the maximum score from the list of candidates.
22
- func (msp * MaxScorePicker ) Pick (ctx * types.SchedulingContext , pods []types.Pod ) ( * types.Result , error ) {
23
+ func (msp * MaxScorePicker ) Pick (ctx * types.SchedulingContext , pods []types.Pod ) * types.Result {
23
24
debugLogger := ctx .Logger .V (logutil .DEBUG ).WithName ("max-score-picker" )
24
25
debugLogger .Info (fmt .Sprintf ("Selecting the pod with the max score from %d candidates: %+v" ,
25
26
len (pods ), pods ))
@@ -38,17 +39,17 @@ func (msp *MaxScorePicker) Pick(ctx *types.SchedulingContext, pods []types.Pod)
38
39
}
39
40
40
41
if len (winners ) == 0 {
41
- return nil , nil
42
+ return nil
42
43
}
43
44
44
45
if len (winners ) > 1 {
45
46
debugLogger .Info (fmt .Sprintf ("Multiple pods have the same max score (%f): %+v" ,
46
47
maxScore , winners ))
47
48
48
49
randomPicker := RandomPicker {}
49
- return randomPicker .Pick (ctx , winners ), nil
50
+ return randomPicker .Pick (ctx , winners )
50
51
}
51
52
52
53
debugLogger .Info (fmt .Sprintf ("Selected pod with max score (%f): %+v" , maxScore , winners [0 ]))
53
- return & types.Result {TargetPod : winners [0 ]}, nil
54
+ return & types.Result {TargetPod : winners [0 ]}
54
55
}
0 commit comments