Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions pkg/epp/requestcontrol/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,18 @@ func (d *Director) prepareRequest(ctx context.Context, reqCtx *handlers.RequestC
return reqCtx, err
}
targetPods := []*backend.Pod{}
if len(pool.Spec.TargetPorts) != 1 {
return reqCtx, errutil.Error{Code: errutil.BadRequest, Msg: "targetPorts should have length 1"}
if len(pool.Spec.TargetPorts) > 8 {
return reqCtx, errutil.Error{Code: errutil.BadRequest, Msg: "targetPorts should have length less than 8"}
}
targetPort := int(pool.Spec.TargetPorts[0].Number)
targetEndpoints := []string{}

for _, pod := range result.ProfileResults[result.PrimaryProfileName].TargetPods {
curPod := pod.GetPod()
curEndpoint := net.JoinHostPort(curPod.Address, strconv.Itoa(targetPort))
targetPods = append(targetPods, curPod)
targetEndpoints = append(targetEndpoints, curEndpoint)
for _, tp := range pool.Spec.TargetPorts {
curEndpoint := net.JoinHostPort(curPod.Address, strconv.Itoa(int(tp.Number)))
targetPods = append(targetPods, curPod)
targetEndpoints = append(targetEndpoints, curEndpoint)
}
}

multiEndpointString := strings.Join(targetEndpoints, ",")
Expand All @@ -245,7 +246,7 @@ func (d *Director) prepareRequest(ctx context.Context, reqCtx *handlers.RequestC
reqCtx.TargetPod = targetPods[0]
reqCtx.TargetEndpoint = multiEndpointString

d.runPreRequestPlugins(ctx, reqCtx.SchedulingRequest, result, targetPort)
d.runPreRequestPlugins(ctx, reqCtx.SchedulingRequest, result)

return reqCtx, nil
}
Expand Down Expand Up @@ -313,12 +314,12 @@ func (d *Director) GetRandomPod() *backend.Pod {
}

func (d *Director) runPreRequestPlugins(ctx context.Context, request *schedulingtypes.LLMRequest,
schedulingResult *schedulingtypes.SchedulingResult, targetPort int) {
schedulingResult *schedulingtypes.SchedulingResult) {
loggerDebug := log.FromContext(ctx).V(logutil.DEBUG)
for _, plugin := range d.requestControlPlugins.preRequestPlugins {
loggerDebug.Info("Running PreRequest plugin", "plugin", plugin.TypedName())
before := time.Now()
plugin.PreRequest(ctx, request, schedulingResult, targetPort)
plugin.PreRequest(ctx, request, schedulingResult, 0) // Using 0 as a placeholder targetPort. The actual value is ignored by the underlying implementation.
metrics.RecordPluginProcessingLatency(PreRequestExtensionPoint, plugin.TypedName().Type, plugin.TypedName().Name, time.Since(before))
loggerDebug.Info("Completed running PreRequest plugin successfully", "plugin", plugin.TypedName())
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/epp/requestcontrol/director_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestDirector_HandleRequest(t *testing.T) {
pool := &v1.InferencePool{
ObjectMeta: metav1.ObjectMeta{Name: "test-pool", Namespace: "default"},
Spec: v1.InferencePoolSpec{
TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8000))}},
TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8000))}, {Number: v1.PortNumber(int32(8001))}},
Selector: v1.LabelSelector{
MatchLabels: map[v1.LabelKey]v1.LabelValue{
"app": "inference",
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestDirector_HandleRequest(t *testing.T) {
NamespacedName: types.NamespacedName{Namespace: "default", Name: "pod1"},
Address: "192.168.1.100",
},
TargetEndpoint: "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000",
TargetEndpoint: "192.168.1.100:8000,192.168.1.100:8001,192.168.2.100:8000,192.168.2.100:8001,192.168.4.100:8000,192.168.4.100:8001",
},
wantMutatedBodyModel: model,
inferenceObjectiveName: objectiveName,
Expand All @@ -250,7 +250,7 @@ func TestDirector_HandleRequest(t *testing.T) {
NamespacedName: types.NamespacedName{Namespace: "default", Name: "pod1"},
Address: "192.168.1.100",
},
TargetEndpoint: "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000",
TargetEndpoint: "192.168.1.100:8000,192.168.1.100:8001,192.168.2.100:8000,192.168.2.100:8001,192.168.4.100:8000,192.168.4.100:8001",
},
wantMutatedBodyModel: model,
targetModelName: model,
Expand Down Expand Up @@ -281,7 +281,7 @@ func TestDirector_HandleRequest(t *testing.T) {
NamespacedName: types.NamespacedName{Namespace: "default", Name: "pod1"},
Address: "192.168.1.100",
},
TargetEndpoint: "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000",
TargetEndpoint: "192.168.1.100:8000,192.168.1.100:8001,192.168.2.100:8000,192.168.2.100:8001,192.168.4.100:8000,192.168.4.100:8001",
},
wantMutatedBodyModel: model,
inferenceObjectiveName: objectiveName,
Expand All @@ -304,7 +304,7 @@ func TestDirector_HandleRequest(t *testing.T) {
NamespacedName: types.NamespacedName{Namespace: "default", Name: "pod1"},
Address: "192.168.1.100",
},
TargetEndpoint: "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000",
TargetEndpoint: "192.168.1.100:8000,192.168.1.100:8001,192.168.2.100:8000,192.168.2.100:8001,192.168.4.100:8000,192.168.4.100:8001",
},
wantMutatedBodyModel: "resolved-target-model-A",
inferenceObjectiveName: objectiveNameResolve,
Expand All @@ -322,7 +322,7 @@ func TestDirector_HandleRequest(t *testing.T) {
NamespacedName: types.NamespacedName{Namespace: "default", Name: "pod1"},
Address: "192.168.1.100",
},
TargetEndpoint: "192.168.1.100:8000,192.168.2.100:8000,192.168.4.100:8000",
TargetEndpoint: "192.168.1.100:8000,192.168.1.100:8001,192.168.2.100:8000,192.168.2.100:8001,192.168.4.100:8000,192.168.4.100:8001",
},
wantMutatedBodyModel: "food-review-1",
reqBodyMap: map[string]any{
Expand Down