@@ -3,6 +3,7 @@ package backend
3
3
import (
4
4
"context"
5
5
"strconv"
6
+ "time"
6
7
7
8
"inference.networking.x-k8s.io/gateway-api-inference-extension/api/v1alpha1"
8
9
logutil "inference.networking.x-k8s.io/gateway-api-inference-extension/pkg/ext-proc/util/logging"
@@ -30,17 +31,19 @@ type EndpointSliceReconciler struct {
30
31
}
31
32
32
33
func (c * EndpointSliceReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
34
+ inferencePool , err := c .Datastore .getInferencePool ()
35
+ if err != nil {
36
+ klog .V (logutil .DEFAULT ).Infof ("Skipping reconciling EndpointSlice because the InferencePool is not available yet: %v" , err )
37
+ return ctrl.Result {Requeue : true , RequeueAfter : time .Second }, nil
38
+ }
39
+
33
40
klog .V (logutil .DEFAULT ).Info ("Reconciling EndpointSlice " , req .NamespacedName )
34
41
35
42
endpointSlice := & discoveryv1.EndpointSlice {}
36
43
if err := c .Get (ctx , req .NamespacedName , endpointSlice ); err != nil {
37
44
klog .Errorf ("Unable to get EndpointSlice: %v" , err )
38
45
return ctrl.Result {}, err
39
46
}
40
- inferencePool , err := c .Datastore .getInferencePool ()
41
- if err != nil {
42
- return ctrl.Result {}, err
43
- }
44
47
c .updateDatastore (endpointSlice , inferencePool )
45
48
46
49
return ctrl.Result {}, nil
@@ -81,14 +84,6 @@ func (c *EndpointSliceReconciler) updateDatastore(
81
84
}
82
85
83
86
func (c * EndpointSliceReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
84
- inferencePoolAvailable := func (object client.Object ) bool {
85
- _ , err := c .Datastore .getInferencePool ()
86
- if err != nil {
87
- klog .V (logutil .DEFAULT ).Infof ("Skipping reconciling EndpointSlice because the InferencePool is not available yet: %v" , err )
88
- }
89
- return err == nil
90
- }
91
-
92
87
ownsEndPointSlice := func (object client.Object ) bool {
93
88
// Check if the object is an EndpointSlice
94
89
endpointSlice , ok := object .(* discoveryv1.EndpointSlice )
@@ -98,17 +93,12 @@ func (c *EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) error {
98
93
99
94
gotLabel := endpointSlice .ObjectMeta .Labels [serviceOwnerLabel ]
100
95
wantLabel := c .ServiceName
101
- if gotLabel != wantLabel {
102
- namesapcedName := endpointSlice .ObjectMeta .Namespace + "/" + endpointSlice .ObjectMeta .Name
103
- 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 )
104
- }
105
96
return gotLabel == wantLabel
106
97
}
107
98
108
99
return ctrl .NewControllerManagedBy (mgr ).
109
100
For (& discoveryv1.EndpointSlice {},
110
- builder .WithPredicates (predicate .NewPredicateFuncs (inferencePoolAvailable ),
111
- predicate .NewPredicateFuncs (ownsEndPointSlice ))).
101
+ builder .WithPredicates (predicate .NewPredicateFuncs (ownsEndPointSlice ))).
112
102
Complete (c )
113
103
}
114
104
0 commit comments