Skip to content

Commit 95d6bef

Browse files
committed
response to comments
Signed-off-by: roytman <roytman@il.ibm.com>
1 parent 86401f7 commit 95d6bef

3 files changed

Lines changed: 18 additions & 25 deletions

File tree

pkg/epp/framework/plugins/scheduling/profilehandler/headerphase/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Reads the configured header from the incoming request and looks up the
1313
`schedulingProfiles` entry with that exact name:
1414

1515
- With exactly one profile configured, that profile always runs, regardless of the
16-
header (or its absence). There is nothing else to disaggregate to, so a deployment
17-
scaled down to a single stage -- or one that never disaggregates at all -- works
16+
header (or its absence). There is nothing else to choose, so a deployment
17+
scaled down to a single stage -- or one that never chooses at all -- works
1818
without swapping to a different profile handler.
1919
- With more than one profile configured and a matching profile named by the header, it
2020
runs that profile alone.

pkg/epp/framework/plugins/scheduling/profilehandler/headerphase/header_phase_profile_handler.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"sigs.k8s.io/controller-runtime/pkg/log"
2626

27-
"github.com/llm-d/llm-d-router/pkg/common/observability/logging"
2827
fwkplugin "github.com/llm-d/llm-d-router/pkg/epp/framework/interface/plugin"
2928
fwksched "github.com/llm-d/llm-d-router/pkg/epp/framework/interface/scheduling"
3029
)
@@ -82,6 +81,9 @@ func Factory(name string, rawParameters *json.Decoder, _ fwkplugin.Handle) (fwkp
8281
func NewHeaderPhaseProfileHandler(headerName, defaultProfile string) *HeaderPhaseProfileHandler {
8382
headerName = strings.ToLower(strings.TrimSpace(headerName))
8483
if headerName == "" {
84+
// defaultHeaderName is kept mixed-case for the README and for the tests that use
85+
// it as a mixed-case constructor input, so it needs the same normalization here
86+
// as any other headerName.
8587
headerName = strings.ToLower(defaultHeaderName)
8688
}
8789

@@ -104,7 +106,7 @@ func NewHeaderPhaseProfileHandler(headerName, defaultProfile string) *HeaderPhas
104106
// handler, which decides which profiles to run via decider plugins.
105107
//
106108
// Two fallbacks keep single-stage and header-less traffic working without a different
107-
// profile handler: with exactly one configured profile there is nothing to disaggregate,
109+
// profile handler: with exactly one configured profile there is nothing to choose,
108110
// so that profile always runs regardless of the header (or its absence); with more than
109111
// one configured profile, a request whose header is missing or blank runs defaultProfile
110112
// instead of failing. A header naming a profile that isn't configured is still an error -
@@ -173,7 +175,7 @@ func (h *HeaderPhaseProfileHandler) Pick(ctx context.Context, request *fwksched.
173175
return map[string]fwksched.SchedulerProfile{}
174176
}
175177

176-
// With exactly one configured profile there is nothing to disaggregate: always run
178+
// With exactly one configured profile there is nothing to choose: always run
177179
// it, so a deployment scaled down to a single stage works without swapping profile
178180
// handlers or requiring every caller to send the header.
179181
if len(profiles) == 1 {
@@ -191,9 +193,10 @@ func (h *HeaderPhaseProfileHandler) Pick(ctx context.Context, request *fwksched.
191193
profile, ok := profiles[resolvedPhase]
192194
if !ok {
193195
// A missing or unrecognized header value is a per-request client issue, not a
194-
// system fault - log at DEBUG via Info, not Error, so it doesn't page anyone or
195-
// drown out real errors: logr.Logger.Error always emits regardless of V-level,
196-
// only Info is verbosity-gated.
196+
// system fault - log via Info, not Error, so it doesn't page anyone or drown out
197+
// real errors. It's still a once-per-request operational signal an operator needs
198+
// to see by default, so it's unguarded rather than gated behind a verbosity level
199+
// that's off in production.
197200
// A missing header whose defaultProfile substitute also fails to resolve is a
198201
// distinct, config-time condition - it fails every header-less request, not just
199202
// an occasional bad caller - so it gets its own message rather than being
@@ -202,7 +205,7 @@ func (h *HeaderPhaseProfileHandler) Pick(ctx context.Context, request *fwksched.
202205
if phase == "" {
203206
err = h.defaultProfileNotConfiguredError()
204207
}
205-
log.FromContext(ctx).V(logging.DEBUG).Info("no scheduling profile selected for request", "error", err)
208+
log.FromContext(ctx).Info("no scheduling profile selected for request", "error", err)
206209
return map[string]fwksched.SchedulerProfile{}
207210
}
208211

pkg/epp/framework/plugins/scheduling/profilehandler/headerphase/header_phase_profile_handler_test.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestNewHeaderPhaseProfileHandler(t *testing.T) {
5353
}
5454

5555
func TestNewHeaderPhaseProfileHandlerEmptyFallsBackToDefault(t *testing.T) {
56-
// The constructor itself must uphold the "never empty" invariant, independent of
56+
// The constructor itself must uphold the "never empty" invariant, independent of the
5757
// Factory: an empty headerName/defaultProfile must not produce a handler that can
5858
// never match any request (request.Headers[""] is always empty, and an empty
5959
// defaultProfile could never name a real schedulingProfiles entry).
@@ -290,7 +290,7 @@ func TestHeaderPhasePick(t *testing.T) {
290290
},
291291
{
292292
// With exactly one configured profile, it always runs -- even with no
293-
// header at all -- since there is nothing else to disaggregate to. This is
293+
// header at all -- since there is nothing else to choose. This is
294294
// what makes a deployment scaled down to a single stage work without
295295
// swapping to a different profile handler.
296296
name: "single configured profile runs with no header",
@@ -315,13 +315,8 @@ func TestHeaderPhasePick(t *testing.T) {
315315
for _, tt := range tests {
316316
t.Run(tt.name, func(t *testing.T) {
317317
got := handler.Pick(context.Background(), tt.request, tt.profiles, tt.profileResults)
318-
if len(got) != len(tt.wantProfiles) {
319-
t.Errorf("Pick() returned %d profiles, want %d", len(got), len(tt.wantProfiles))
320-
}
321-
for name := range tt.wantProfiles {
322-
if _, ok := got[name]; !ok {
323-
t.Errorf("Pick() missing expected profile %q", name)
324-
}
318+
if diff := cmp.Diff(tt.wantProfiles, got); diff != "" {
319+
t.Errorf("Pick() returned unexpected profiles (-want +got): %s", diff)
325320
}
326321
})
327322
}
@@ -360,13 +355,8 @@ func TestHeaderPhasePickCustomDefaultProfile(t *testing.T) {
360355
for _, tt := range tests {
361356
t.Run(tt.name, func(t *testing.T) {
362357
got := handler.Pick(context.Background(), tt.request, profiles, map[string]*fwksched.ProfileRunResult{})
363-
if len(got) != len(tt.wantProfiles) {
364-
t.Errorf("Pick() returned %d profiles, want %d", len(got), len(tt.wantProfiles))
365-
}
366-
for name := range tt.wantProfiles {
367-
if _, ok := got[name]; !ok {
368-
t.Errorf("Pick() missing expected profile %q", name)
369-
}
358+
if diff := cmp.Diff(tt.wantProfiles, got); diff != "" {
359+
t.Errorf("Pick() returned unexpected profiles (-want +got): %s", diff)
370360
}
371361
})
372362
}

0 commit comments

Comments
 (0)