Skip to content

Commit f95cf36

Browse files
authored
fix-multiple-scheduling-profiles (#1698)
1 parent 075c837 commit f95cf36

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()
@@ -890,3 +895,23 @@ schedulingProfiles:
890895
plugins:
891896
- pluginRef: maxScore
892897
`
898+
899+
// multiple profiles using SingleProfileHandler
900+
//
901+
//nolint:dupword
902+
const errorMultiProfilesUseSingleProfileHandlerText = `
903+
apiVersion: inference.networking.x-k8s.io/v1alpha1
904+
kind: EndpointPickerConfig
905+
plugins:
906+
- name: profileHandler
907+
type: single-profile-handler
908+
- name: maxScore
909+
type: max-score-picker
910+
schedulingProfiles:
911+
- name: default
912+
plugins:
913+
- pluginRef: maxScore
914+
- name: prof2
915+
plugins:
916+
- pluginRef: maxScore
917+
`

0 commit comments

Comments
 (0)