Skip to content

Commit 1a0e211

Browse files
learner0810BenjaminBraunDev
authored andcommitted
fix-multiple-scheduling-profiles (kubernetes-sigs#1698)
1 parent 99eedcf commit 1a0e211

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pkg/epp/config/loader/configloader.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
3232
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling"
3333
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework"
34+
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/profile"
3435
)
3536

3637
var scheme = runtime.NewScheme()
@@ -113,6 +114,10 @@ func loadSchedulerConfig(configProfiles []configapi.SchedulingProfile, handle pl
113114
return nil, errors.New("no profile handler was specified")
114115
}
115116

117+
if profileHandler.TypedName().Type == profile.SingleProfileHandlerType && len(profiles) > 1 {
118+
return nil, errors.New("single profile handler is intended to be used with a single profile, but multiple profiles were specified")
119+
}
120+
116121
return scheduling.NewSchedulerConfig(profileHandler, profiles), nil
117122
}
118123

pkg/epp/config/loader/configloader_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ func TestLoadConfig(t *testing.T) {
420420
configText: errorNoProfileHandlersText,
421421
wantErr: true,
422422
},
423+
{
424+
name: "errorMultiProfilesUseSingleProfileHandler",
425+
configText: errorMultiProfilesUseSingleProfileHandlerText,
426+
wantErr: true,
427+
},
423428
}
424429

425430
registerNeededPlgugins()
@@ -895,3 +900,23 @@ schedulingProfiles:
895900
plugins:
896901
- pluginRef: maxScore
897902
`
903+
904+
// multiple profiles using SingleProfileHandler
905+
//
906+
//nolint:dupword
907+
const errorMultiProfilesUseSingleProfileHandlerText = `
908+
apiVersion: inference.networking.x-k8s.io/v1alpha1
909+
kind: EndpointPickerConfig
910+
plugins:
911+
- name: profileHandler
912+
type: single-profile-handler
913+
- name: maxScore
914+
type: max-score-picker
915+
schedulingProfiles:
916+
- name: default
917+
plugins:
918+
- pluginRef: maxScore
919+
- name: prof2
920+
plugins:
921+
- pluginRef: maxScore
922+
`

0 commit comments

Comments
 (0)