From a30410cd67954a7c4615cd60bf48c0fcdb7dda85 Mon Sep 17 00:00:00 2001 From: bjee19 <139261241+bjee19@users.noreply.github.com> Date: Mon, 20 Oct 2025 09:14:00 -0700 Subject: [PATCH] Add conditional on listing inference pools (#4104) Add a conditional to inference pool status, so we make a k8sclient call on the InferencePool object only if inference extension is enabled. --- internal/controller/handler.go | 28 ++++++++++++++++------------ internal/controller/manager.go | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/internal/controller/handler.go b/internal/controller/handler.go index 861e45c99f..e2c08db82b 100644 --- a/internal/controller/handler.go +++ b/internal/controller/handler.go @@ -88,6 +88,8 @@ type eventHandlerConfig struct { gatewayClassName string // plus is whether or not we are running NGINX Plus. plus bool + // InferenceExtension indicates if Gateway API Inference Extension support is enabled. + inferenceExtension bool } const ( @@ -372,18 +374,20 @@ func (h *eventHandlerImpl) updateStatuses(ctx context.Context, gr *graph.Graph, // unfortunately, status is not on clusterState stored by the change processor, so we need to make a k8sAPI call here ipList := &inference.InferencePoolList{} - err = h.cfg.k8sClient.List(ctx, ipList) - if err != nil { - msg := "error listing InferencePools for status update" - h.cfg.logger.Error(err, msg) - h.cfg.eventRecorder.Eventf( - &inference.InferencePoolList{}, - v1.EventTypeWarning, - "ListInferencePoolsFailed", - msg+": %s", - err.Error(), - ) - ipList = &inference.InferencePoolList{} // reset to empty list to avoid nil pointer dereference + if h.cfg.inferenceExtension { + err = h.cfg.k8sClient.List(ctx, ipList) + if err != nil { + msg := "error listing InferencePools for status update" + h.cfg.logger.Error(err, msg) + h.cfg.eventRecorder.Eventf( + &inference.InferencePoolList{}, + v1.EventTypeWarning, + "ListInferencePoolsFailed", + msg+": %s", + err.Error(), + ) + ipList = &inference.InferencePoolList{} // reset to empty list to avoid nil pointer dereference + } } inferencePoolReqs := status.PrepareInferencePoolRequests( gr.ReferencedInferencePools, diff --git a/internal/controller/manager.go b/internal/controller/manager.go index dc9c4835bd..264f51cf96 100644 --- a/internal/controller/manager.go +++ b/internal/controller/manager.go @@ -259,6 +259,7 @@ func StartManager(cfg config.Config) error { plus: cfg.Plus, statusQueue: statusQueue, nginxDeployments: nginxUpdater.NginxDeployments, + inferenceExtension: cfg.InferenceExtension, }) objects, objectLists := prepareFirstEventBatchPreparerArgs(cfg)