Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requeue reconcile requests for endpointslice until the inferencepool is available #248

Merged
merged 1 commit into from
Jan 29, 2025
Merged
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
26 changes: 8 additions & 18 deletions pkg/ext-proc/backend/endpointslice_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package backend
import (
"context"
"strconv"
"time"

"inference.networking.x-k8s.io/gateway-api-inference-extension/api/v1alpha1"
logutil "inference.networking.x-k8s.io/gateway-api-inference-extension/pkg/ext-proc/util/logging"
Expand Down Expand Up @@ -30,17 +31,19 @@ type EndpointSliceReconciler struct {
}

func (c *EndpointSliceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
inferencePool, err := c.Datastore.getInferencePool()
if err != nil {
klog.V(logutil.DEFAULT).Infof("Skipping reconciling EndpointSlice because the InferencePool is not available yet: %v", err)
return ctrl.Result{Requeue: true, RequeueAfter: time.Second}, nil
}

klog.V(logutil.DEFAULT).Info("Reconciling EndpointSlice ", req.NamespacedName)

endpointSlice := &discoveryv1.EndpointSlice{}
if err := c.Get(ctx, req.NamespacedName, endpointSlice); err != nil {
klog.Errorf("Unable to get EndpointSlice: %v", err)
return ctrl.Result{}, err
}
inferencePool, err := c.Datastore.getInferencePool()
if err != nil {
return ctrl.Result{}, err
}
c.updateDatastore(endpointSlice, inferencePool)

return ctrl.Result{}, nil
Expand Down Expand Up @@ -81,14 +84,6 @@ func (c *EndpointSliceReconciler) updateDatastore(
}

func (c *EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) error {
inferencePoolAvailable := func(object client.Object) bool {
_, err := c.Datastore.getInferencePool()
if err != nil {
klog.V(logutil.DEFAULT).Infof("Skipping reconciling EndpointSlice because the InferencePool is not available yet: %v", err)
}
return err == nil
}

ownsEndPointSlice := func(object client.Object) bool {
// Check if the object is an EndpointSlice
endpointSlice, ok := object.(*discoveryv1.EndpointSlice)
Expand All @@ -98,17 +93,12 @@ func (c *EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) error {

gotLabel := endpointSlice.ObjectMeta.Labels[serviceOwnerLabel]
wantLabel := c.ServiceName
if gotLabel != wantLabel {
namesapcedName := endpointSlice.ObjectMeta.Namespace + "/" + endpointSlice.ObjectMeta.Name
klog.V(logutil.DEFAULT).Infof("Skipping EndpointSlice %v because its service owner label %v doesn't match the pool service name %v", namesapcedName, gotLabel, wantLabel)
}
return gotLabel == wantLabel
}

return ctrl.NewControllerManagedBy(mgr).
For(&discoveryv1.EndpointSlice{},
builder.WithPredicates(predicate.NewPredicateFuncs(inferencePoolAvailable),
predicate.NewPredicateFuncs(ownsEndPointSlice))).
builder.WithPredicates(predicate.NewPredicateFuncs(ownsEndPointSlice))).
Complete(c)
}

Expand Down