Skip to content

Commit 0d81658

Browse files
committed
Changes due to type name changes
Signed-off-by: Shmuel Kallner <[email protected]>
1 parent 3cc2283 commit 0d81658

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

pkg/epp/scheduling/framework/plugins/scorer/running.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ func (s *RunningRequestsSizeScorer) WithName(name string) *RunningRequestsSizeSc
7171
}
7272

7373
// Score returns the scoring result for the given list of pods based on context.
74-
func (s *RunningRequestsSizeScorer) Score(_ context.Context, _ *types.CycleState, _ *types.LLMRequest, pods []types.Pod) map[types.Pod]float64 {
74+
func (s *RunningRequestsSizeScorer) Score(_ context.Context, _ *types.CycleState, _ *types.LLMRequest, endpoints []types.Endpoint) map[types.Endpoint]float64 {
7575
minQueueSize := math.MaxInt
7676
maxQueueSize := math.MinInt
7777

7878
// Iterate through the remaining pods to find min and max
79-
for _, pod := range pods {
80-
queueSize := pod.GetMetrics().RunningRequestsSize
79+
for _, endpoint := range endpoints {
80+
queueSize := endpoint.GetMetrics().RunningRequestsSize
8181
if queueSize < minQueueSize {
8282
minQueueSize = queueSize
8383
}
@@ -86,19 +86,19 @@ func (s *RunningRequestsSizeScorer) Score(_ context.Context, _ *types.CycleState
8686
}
8787
}
8888

89-
// podScoreFunc calculates the score based on the queue size of each pod. Longer queue gets a lower score.
90-
podScoreFunc := func(pod types.Pod) float64 {
89+
// endpointScoreFunc calculates the score based on the queue size of each pod. Longer queue gets a lower score.
90+
endpointScoreFunc := func(endpoint types.Endpoint) float64 {
9191
if maxQueueSize == minQueueSize {
9292
// If all pods have the same queue size, return a neutral score
9393
return 1.0
9494
}
95-
return float64(maxQueueSize-pod.GetMetrics().RunningRequestsSize) / float64(maxQueueSize-minQueueSize)
95+
return float64(maxQueueSize-endpoint.GetMetrics().RunningRequestsSize) / float64(maxQueueSize-minQueueSize)
9696
}
9797

9898
// Create a map to hold the scores for each pod
99-
scores := make(map[types.Pod]float64, len(pods))
100-
for _, pod := range pods {
101-
scores[pod] = podScoreFunc(pod)
99+
scores := make(map[types.Endpoint]float64, len(endpoints))
100+
for _, endpoint := range endpoints {
101+
scores[endpoint] = endpointScoreFunc(endpoint)
102102
}
103103
return scores
104104
}

pkg/epp/scheduling/framework/plugins/scorer/running_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ import (
2222

2323
"github.com/stretchr/testify/assert"
2424

25-
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend"
2625
backendmetrics "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend/metrics"
26+
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer"
2727
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
2828
)
2929

3030
func TestRunningRequestsSizeScorer(t *testing.T) {
3131
tests := []struct {
3232
name string
33-
pods []types.Pod
33+
endpoints []types.Endpoint
3434
expectedScoresPod map[int]float64 // Map of pod index to expected score
3535
}{
3636
{
3737
name: "Different running queue sizes",
38-
pods: []types.Pod{
39-
&types.PodMetrics{Pod: &backend.Pod{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 10}},
40-
&types.PodMetrics{Pod: &backend.Pod{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 5}},
41-
&types.PodMetrics{Pod: &backend.Pod{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 0}},
38+
endpoints: []types.Endpoint{
39+
&types.PodMetrics{EndpointMetadata: &datalayer.EndpointMetadata{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 10}},
40+
&types.PodMetrics{EndpointMetadata: &datalayer.EndpointMetadata{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 5}},
41+
&types.PodMetrics{EndpointMetadata: &datalayer.EndpointMetadata{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 0}},
4242
},
4343
expectedScoresPod: map[int]float64{
4444
0: 0.0, // Longest queue (10) gets lowest score
@@ -48,9 +48,9 @@ func TestRunningRequestsSizeScorer(t *testing.T) {
4848
},
4949
{
5050
name: "Same running queue sizes",
51-
pods: []types.Pod{
52-
&types.PodMetrics{Pod: &backend.Pod{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 5}},
53-
&types.PodMetrics{Pod: &backend.Pod{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 5}},
51+
endpoints: []types.Endpoint{
52+
&types.PodMetrics{EndpointMetadata: &datalayer.EndpointMetadata{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 5}},
53+
&types.PodMetrics{EndpointMetadata: &datalayer.EndpointMetadata{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 5}},
5454
},
5555
expectedScoresPod: map[int]float64{
5656
0: 1.0, // When all pods have the same queue size, they get the same neutral score
@@ -59,9 +59,9 @@ func TestRunningRequestsSizeScorer(t *testing.T) {
5959
},
6060
{
6161
name: "Zero running queue sizes",
62-
pods: []types.Pod{
63-
&types.PodMetrics{Pod: &backend.Pod{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 0}},
64-
&types.PodMetrics{Pod: &backend.Pod{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 0}},
62+
endpoints: []types.Endpoint{
63+
&types.PodMetrics{EndpointMetadata: &datalayer.EndpointMetadata{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 0}},
64+
&types.PodMetrics{EndpointMetadata: &datalayer.EndpointMetadata{}, MetricsState: &backendmetrics.MetricsState{RunningRequestsSize: 0}},
6565
},
6666
expectedScoresPod: map[int]float64{
6767
0: 1.0,
@@ -74,9 +74,9 @@ func TestRunningRequestsSizeScorer(t *testing.T) {
7474

7575
for _, test := range tests {
7676
t.Run(test.name, func(t *testing.T) {
77-
scores := scorer.Score(context.Background(), types.NewCycleState(), &types.LLMRequest{}, test.pods)
77+
scores := scorer.Score(context.Background(), types.NewCycleState(), &types.LLMRequest{}, test.endpoints)
7878

79-
for i, pod := range test.pods {
79+
for i, pod := range test.endpoints {
8080
expectedScore := test.expectedScoresPod[i]
8181
assert.InDelta(t, expectedScore, scores[pod], 0.0001, "Pod %d should have score %f", i, expectedScore)
8282
}

0 commit comments

Comments
 (0)