Skip to content
Merged
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
18 changes: 15 additions & 3 deletions pkg/bbr/handlers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func (s *Server) Process(srv extProcPb.ExternalProcessor_ProcessServer) error {
responses, err = s.HandleRequestHeaders(req.GetRequestHeaders())
}
case *extProcPb.ProcessingRequest_RequestBody:
loggerVerbose.Info("Incoming body chunk", "body", string(v.RequestBody.Body), "EoS", v.RequestBody.EndOfStream)
if logger.V(logutil.DEBUG).Enabled() {
logger.V(logutil.DEBUG).Info("Incoming body chunk", "body", string(v.RequestBody.Body), "EoS", v.RequestBody.EndOfStream)
} else {
loggerVerbose.Info("Incoming body chunk", "EoS", v.RequestBody.EndOfStream)
}
responses, err = s.processRequestBody(ctx, req.GetRequestBody(), streamedBody, logger)
case *extProcPb.ProcessingRequest_RequestTrailers:
responses, err = s.HandleRequestTrailers(req.GetRequestTrailers())
Expand All @@ -96,12 +100,20 @@ func (s *Server) Process(srv extProcPb.ExternalProcessor_ProcessServer) error {
}

if err != nil {
logger.V(logutil.DEFAULT).Error(err, "Failed to process request", "request", req)
if logger.V(logutil.DEBUG).Enabled() {
logger.V(logutil.DEBUG).Error(err, "Failed to process request", "request", req)
} else {
logger.V(logutil.DEFAULT).Error(err, "Failed to process request")
}
return status.Errorf(status.Code(err), "failed to handle request: %v", err)
}

for _, resp := range responses {
loggerVerbose.Info("Response generated", "response", resp)
if logger.V(logutil.DEBUG).Enabled() {
logger.V(logutil.DEBUG).Info("Response generated", "response", resp)
} else {
loggerVerbose.Info("Response generated")
}
if err := srv.Send(resp); err != nil {
logger.V(logutil.DEFAULT).Error(err, "Send failed")
return status.Errorf(codes.Unknown, "failed to send response back to Envoy: %v", err)
Expand Down
31 changes: 25 additions & 6 deletions pkg/epp/handlers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ func (s *StreamingServer) Process(srv extProcPb.ExternalProcessor_ProcessServer)
loggerTrace.Info("decoding")
err = json.Unmarshal(body, &reqCtx.Request.Body)
if err != nil {
logger.V(logutil.DEFAULT).Error(err, "Error unmarshaling request body")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed to avoid double logs for the same problem

{"level":"error","ts":"2025-07-23T11:07:49Z","caller":"handlers/server.go:210","msg":"Error unmarshaling request body","x-request-id":"3c11cbb0-b7ed-4699-b823-069026d18386","error":"invalid character 'D' after object key:value pair","stacktrace":"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/handlers.(*StreamingServer).Process\n\t/go/pkg/mod/sigs.k8s.io/gateway-api-inference-extension@v0.5.1-rc.1/pkg/epp/handlers/server.go:210\ngithub.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3._ExternalProcessor_Process_Handler\n\t/go/pkg/mod/github.com/envoyproxy/go-control-plane/envoy@v1.32.4/service/ext_proc/v3/external_processor_grpc.pb.go:106\ngoogle.golang.org/grpc.(*Server).processStreamingRPC\n\t/go/pkg/mod/google.golang.org/grpc@v1.73.0/server.go:1695\ngoogle.golang.org/grpc.(*Server).handleStream\n\t/go/pkg/mod/google.golang.org/grpc@v1.73.0/server.go:1819\ngoogle.golang.org/grpc.(*Server).serveStreams.func2.1\n\t/go/pkg/mod/google.golang.org/grpc@v1.73.0/server.go:1035"}
{"level":"error","ts":"2025-07-23T11:07:49Z","caller":"handlers/server.go:310","msg":"Failed to process request","x-request-id":"3c11cbb0-b7ed-4699-b823-069026d18386","request":"request_body:{end_of_stream:true}  metadata_context:{}","error":"inference gateway: BadRequest - Error unmarshaling request body: {\n  \"model\": \"facebook/opt-125m\",\n  \"prompt\": \"\"Delve into the multifaceted implications of a fully disaggregated cloud architecture, specifically where the compute plane (P) and the data plane (D) are independently deployed and managed for a geographically distributed, high-throughput, low-latency microservices ecosystem. Beyond the fundamental challenges of network latency and data consistency, elaborate on the advanced considerations and trade-offs inherent in such a setup: 1. Network Architecture and Protocols: How would the network fabric and underlying protocols (e.g., RDMA, custom transport layers) need to evolve to support optimal performance and minimize inter-plane communication overhead, especially for synchronous operations? Discuss the role of network programmability (e.g., SDN, P4) in dynamically optimizing routing and traffic flow between P and D. 2. Advanced Data Consistency and Durability: Explore sophisticated data consistency models (e.g., causal consistency, strong eventual consistency) and their applicability in balancing performance and data integrity across a globally distributed data plane. Detail strategies for ensuring data durability and fault tolerance, including multi-region replication, intelligent partitioning, and recovery mechanisms in the event of partial or full plane failures. 3. Dynamic Resource Orchestration and Cost Optimization: Analyze how an orchestration layer would intelligently manage the independent scaling of compute (P) and data (D) resources, considering fluctuating workloads, cost efficiency, and performance targets (e.g., using predictive analytics for resource provisioning). Discuss mechanisms for dynamically reallocating compute nodes to different data partitions based on workload patterns and data locality, potentially involving live migration strategies. 4. Security and Compliance in a Distributed Landscape: Address the enhanced security perimeter challenges, including securing communication channels between P and D (encryption in transit, mutual TLS), fine-grained access control to data at rest and in motion, and identity management across disaggregated components. Discuss how such an architecture impacts compliance with regulatory frameworks (e.g., GDPR, HIPAA) concerning data sovereignty, privacy, and auditability. 5. Operational Complexity and Observability: Examine the increased complexity in monitoring, logging, and tracing across highly decoupled compute and data planes. What specialized tooling and practices (e.g., distributed tracing with OpenTelemetry, advanced AIOps) would be essential? How would incident response and troubleshooting differ in this disaggregated environment compared to traditional integrated systems? Consider the challenges of pinpointing root causes across independent failures. 6. Real-world Applicability and Future Trends: Identify specific industries or use cases (e.g., high-frequency trading, IoT edge processing, large language model inference) where the benefits of P/D disaggregation would strongly outweigh its complexities. Conclude by speculating on emerging technologies or paradigms (e.g., serverless compute functions directly interacting with object storage, in-memory disaggregation) that could further drive or transform P/D disaggregation in cloud computing.\", \n  \"stream\": false, \n  \"max_tokens\": 50}","stacktrace":"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/handlers.(*StreamingServer).Process\n\t/go/pkg/mod/sigs.k8s.io/gateway-api-inference-extension@v0.5.1-rc.1/pkg/epp/handlers/server.go:310\ngithub.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3._ExternalProcessor_Process_Handler\n\t/go/pkg/mod/github.com/envoyproxy/go-control-plane/envoy@v1.32.4/service/ext_proc/v3/external_processor_grpc.pb.go:106\ngoogle.golang.org/grpc.(*Server).processStreamingRPC\n\t/go/pkg/mod/google.golang.org/grpc@v1.73.0/server.go:1695\ngoogle.golang.org/grpc.(*Server).handleStream\n\t/go/pkg/mod/google.golang.org/grpc@v1.73.0/server.go:1819\ngoogle.golang.org/grpc.(*Server).serveStreams.func2.1\n\t/go/pkg/mod/google.golang.org/grpc@v1.73.0/server.go:1035"}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

err = errutil.Error{Code: errutil.BadRequest, Msg: "Error unmarshaling request body: " + string(body)}
if logger.V(logutil.DEBUG).Enabled() {
err = errutil.Error{Code: errutil.BadRequest, Msg: "Error unmarshaling request body: " + string(body)}
} else {
err = errutil.Error{Code: errutil.BadRequest, Msg: "Error unmarshaling request body"}
}
break
}

Expand Down Expand Up @@ -253,7 +256,11 @@ func (s *StreamingServer) Process(srv extProcPb.ExternalProcessor_ProcessServer)
var responseErr error
reqCtx, responseErr = s.HandleResponseHeaders(ctx, reqCtx, v)
if responseErr != nil {
logger.V(logutil.DEFAULT).Error(responseErr, "Failed to process response headers", "request", req)
if logger.V(logutil.DEBUG).Enabled() {
logger.V(logutil.DEBUG).Error(responseErr, "Failed to process response headers", "request", req)
} else {
logger.V(logutil.DEFAULT).Error(responseErr, "Failed to process response headers")
}
}
reqCtx.respHeaderResp = s.generateResponseHeaderResponse(reqCtx)

Expand Down Expand Up @@ -284,14 +291,22 @@ func (s *StreamingServer) Process(srv extProcPb.ExternalProcessor_ProcessServer)
var responseErr error
responseErr = json.Unmarshal(body, &responseBody)
if responseErr != nil {
logger.V(logutil.DEFAULT).Error(responseErr, "Error unmarshaling request body", "body", string(body))
if logger.V(logutil.DEBUG).Enabled() {
logger.V(logutil.DEBUG).Error(responseErr, "Error unmarshalling request body", "body", string(body))
} else {
logger.V(logutil.DEFAULT).Error(responseErr, "Error unmarshalling request body")
}
reqCtx.respBodyResp = generateResponseBodyResponses(body, true)
break
}

reqCtx, responseErr = s.HandleResponseBody(ctx, reqCtx, responseBody)
if responseErr != nil {
logger.V(logutil.DEFAULT).Error(responseErr, "Failed to process response body", "request", req)
if logger.V(logutil.DEBUG).Enabled() {
logger.V(logutil.DEBUG).Error(responseErr, "Failed to process response body", "request", req)
} else {
logger.V(logutil.DEFAULT).Error(responseErr, "Failed to process response body")
}
} else if reqCtx.ResponseComplete {
reqCtx.ResponseCompleteTimestamp = time.Now()
metrics.RecordRequestLatencies(ctx, reqCtx.Model, reqCtx.ResolvedTargetModel, reqCtx.RequestReceivedTimestamp, reqCtx.ResponseCompleteTimestamp)
Expand All @@ -307,7 +322,11 @@ func (s *StreamingServer) Process(srv extProcPb.ExternalProcessor_ProcessServer)

// Handle the err and fire an immediate response.
if err != nil {
logger.V(logutil.DEFAULT).Error(err, "Failed to process request", "request", req)
if logger.V(logutil.DEBUG).Enabled() {
logger.V(logutil.DEBUG).Error(err, "Failed to process request", "request", req)
} else {
logger.V(logutil.DEFAULT).Error(err, "Failed to process request")
}
resp, err := buildErrResponse(err)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/epp/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Scheduler struct {

// Schedule finds the target pod based on metrics and the requested lora adapter.
func (s *Scheduler) Schedule(ctx context.Context, request *types.LLMRequest, candidatePods []types.Pod) (*types.SchedulingResult, error) {
logger := log.FromContext(ctx).WithValues("request", request)
logger := log.FromContext(ctx).WithValues("requestId", request.RequestId, "targetModel", request.TargetModel)
loggerDebug := logger.V(logutil.DEBUG)

scheduleStart := time.Now()
Expand Down Expand Up @@ -85,7 +85,7 @@ func (s *Scheduler) Schedule(ctx context.Context, request *types.LLMRequest, can
}

if len(profileRunResults) == 0 {
return nil, fmt.Errorf("failed to run any scheduler profile for the request - %s", request)
return nil, fmt.Errorf("failed to run any scheduler profile for request %s", request.RequestId)
}

loggerDebug.Info("Running profile handler, ProcessResults", "plugin", s.profileHandler.TypedName().Type)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/epp/hermetic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestFullDuplexStreamed_KubeInferenceModelRequest(t *testing.T) {
wantErr: false,
wantResponses: integrationutils.NewImmediateErrorResponse(
envoyTypePb.StatusCode_BadRequest,
"inference gateway: BadRequest - Error unmarshaling request body: no healthy upstream",
"inference gateway: BadRequest - Error unmarshaling request body",
),
},
{
Expand Down