@@ -26,7 +26,6 @@ import (
2626 "strings"
2727 "time"
2828
29- "github.com/go-logr/logr"
3029 "sigs.k8s.io/controller-runtime/pkg/log"
3130
3231 v1 "sigs.k8s.io/gateway-api-inference-extension/api/v1"
@@ -92,10 +91,10 @@ type Director struct {
9291}
9392
9493// getInferenceObjective fetches the inferenceObjective from the datastore otherwise creates a new one based on reqCtx.
95- func (d * Director ) getInferenceObjective (logger logr. Logger , reqCtx * handlers.RequestContext ) * v1alpha2.InferenceObjective {
94+ func (d * Director ) getInferenceObjective (ctx context. Context , reqCtx * handlers.RequestContext ) * v1alpha2.InferenceObjective {
9695 infObjective := d .datastore .ObjectiveGet (reqCtx .ObjectiveKey )
9796 if infObjective == nil {
98- logger .V (logutil .VERBOSE ).Info ("No associated InferenceObjective found, using default" , "objectiveKey" , reqCtx .ObjectiveKey )
97+ log . FromContext ( ctx ) .V (logutil .VERBOSE ).Info ("No associated InferenceObjective found, using default" , "objectiveKey" , reqCtx .ObjectiveKey )
9998 infObjective = & v1alpha2.InferenceObjective {
10099 Spec : v1alpha2.InferenceObjectiveSpec {
101100 Priority : & d .defaultPriority ,
@@ -108,8 +107,7 @@ func (d *Director) getInferenceObjective(logger logr.Logger, reqCtx *handlers.Re
108107 return infObjective
109108}
110109
111- // resolveTargetModel is a helper that resolves targetModel
112- // and updates the reqCtx.
110+ // resolveTargetModel is a helper to update reqCtx with target model based on request.
113111func (d * Director ) resolveTargetModel (reqCtx * handlers.RequestContext ) error {
114112 requestBodyMap := reqCtx .Request .Body
115113 var ok bool
@@ -143,7 +141,7 @@ func (d *Director) HandleRequest(ctx context.Context, reqCtx *handlers.RequestCo
143141 }
144142
145143 // Parse inference objective.
146- infObjective := d .getInferenceObjective (logger , reqCtx )
144+ infObjective := d .getInferenceObjective (ctx , reqCtx )
147145
148146 // Prepare LLMRequest (needed for both saturation detection and Scheduler)
149147 reqCtx .SchedulingRequest = & schedulingtypes.LLMRequest {
@@ -163,7 +161,7 @@ func (d *Director) HandleRequest(ctx context.Context, reqCtx *handlers.RequestCo
163161 if len (candidatePods ) == 0 {
164162 return reqCtx , errutil.Error {Code : errutil .ServiceUnavailable , Msg : "failed to find candidate pods for serving the request" }
165163 }
166-
164+ // TODO(rahulgurnani/lukevandrie): Perhaps, refactor/implement Admit plugin for Admission control.
167165 if err := d .admissionController .Admit (ctx , reqCtx , candidatePods , * infObjective .Spec .Priority ); err != nil {
168166 logger .V (logutil .DEFAULT ).Info ("Request rejected by admission control" , "error" , err )
169167 return reqCtx , err
@@ -360,7 +358,8 @@ func (d *Director) runAdmitRequestPlugins(ctx context.Context,
360358 loggerDebug := log .FromContext (ctx ).V (logutil .DEBUG )
361359 for _ , plugin := range d .requestControlPlugins .admitRequestPlugins {
362360 loggerDebug .Info ("Running AdmitRequest plugin" , "plugin" , plugin .TypedName ())
363- if ! plugin .Admit (ctx , request , pods ) {
361+ if denyReason := plugin .Admit (ctx , request , pods ); denyReason != "" {
362+ loggerDebug .Info ("AdmitRequest plugin denied the request" , "plugin" , plugin .TypedName (), "reason" , denyReason )
364363 return false
365364 }
366365 loggerDebug .Info ("Completed running AdmitRequest plugin successfully" , "plugin" , plugin .TypedName ())
0 commit comments