Skip to content

Commit 1f4392a

Browse files
authored
Add conditional on listing inference pools (#4104) (#4115)
Add a conditional to inference pool status, so we make a k8sclient call on the InferencePool object only if inference extension is enabled.
1 parent e4eed2d commit 1f4392a

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

internal/controller/handler.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ type eventHandlerConfig struct {
8888
gatewayClassName string
8989
// plus is whether or not we are running NGINX Plus.
9090
plus bool
91+
// InferenceExtension indicates if Gateway API Inference Extension support is enabled.
92+
inferenceExtension bool
9193
}
9294

9395
const (
@@ -372,18 +374,20 @@ func (h *eventHandlerImpl) updateStatuses(ctx context.Context, gr *graph.Graph,
372374

373375
// unfortunately, status is not on clusterState stored by the change processor, so we need to make a k8sAPI call here
374376
ipList := &inference.InferencePoolList{}
375-
err = h.cfg.k8sClient.List(ctx, ipList)
376-
if err != nil {
377-
msg := "error listing InferencePools for status update"
378-
h.cfg.logger.Error(err, msg)
379-
h.cfg.eventRecorder.Eventf(
380-
&inference.InferencePoolList{},
381-
v1.EventTypeWarning,
382-
"ListInferencePoolsFailed",
383-
msg+": %s",
384-
err.Error(),
385-
)
386-
ipList = &inference.InferencePoolList{} // reset to empty list to avoid nil pointer dereference
377+
if h.cfg.inferenceExtension {
378+
err = h.cfg.k8sClient.List(ctx, ipList)
379+
if err != nil {
380+
msg := "error listing InferencePools for status update"
381+
h.cfg.logger.Error(err, msg)
382+
h.cfg.eventRecorder.Eventf(
383+
&inference.InferencePoolList{},
384+
v1.EventTypeWarning,
385+
"ListInferencePoolsFailed",
386+
msg+": %s",
387+
err.Error(),
388+
)
389+
ipList = &inference.InferencePoolList{} // reset to empty list to avoid nil pointer dereference
390+
}
387391
}
388392
inferencePoolReqs := status.PrepareInferencePoolRequests(
389393
gr.ReferencedInferencePools,

internal/controller/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ func StartManager(cfg config.Config) error {
259259
plus: cfg.Plus,
260260
statusQueue: statusQueue,
261261
nginxDeployments: nginxUpdater.NginxDeployments,
262+
inferenceExtension: cfg.InferenceExtension,
262263
})
263264

264265
objects, objectLists := prepareFirstEventBatchPreparerArgs(cfg)

0 commit comments

Comments
 (0)