@@ -48,7 +48,7 @@ type Datastore interface {
4848 // PoolSet sets the given pool in datastore. If the given pool has different label selector than the previous pool
4949 // that was stored, the function triggers a resync of the pods to keep the datastore updated. If the given pool
5050 // is nil, this call triggers the datastore.Clear() function.
51- PoolSet (ctx context.Context , client client.Client , pool * v1alpha2.InferencePool ) error
51+ PoolSet (ctx context.Context , reader client.Reader , pool * v1alpha2.InferencePool ) error
5252 PoolGet () (* v1alpha2.InferencePool , error )
5353 PoolHasSynced () bool
5454 PoolLabelsMatch (podLabels map [string ]string ) bool
@@ -57,7 +57,7 @@ type Datastore interface {
5757 ModelSetIfOlder (infModel * v1alpha2.InferenceModel ) bool
5858 ModelGet (modelName string ) * v1alpha2.InferenceModel
5959 ModelDelete (namespacedName types.NamespacedName ) * v1alpha2.InferenceModel
60- ModelResync (ctx context.Context , ctrlClient client.Client , modelName string ) (bool , error )
60+ ModelResync (ctx context.Context , reader client.Reader , modelName string ) (bool , error )
6161 ModelGetAll () []* v1alpha2.InferenceModel
6262
6363 // PodMetrics operations
@@ -110,7 +110,7 @@ func (ds *datastore) Clear() {
110110}
111111
112112// /// InferencePool APIs ///
113- func (ds * datastore ) PoolSet (ctx context.Context , client client.Client , pool * v1alpha2.InferencePool ) error {
113+ func (ds * datastore ) PoolSet (ctx context.Context , reader client.Reader , pool * v1alpha2.InferencePool ) error {
114114 if pool == nil {
115115 ds .Clear ()
116116 return nil
@@ -129,7 +129,7 @@ func (ds *datastore) PoolSet(ctx context.Context, client client.Client, pool *v1
129129 // 2) If the selector on the pool was updated, then we will not get any pod events, and so we need
130130 // to resync the whole pool: remove pods in the store that don't match the new selector and add
131131 // the ones that may have existed already to the store.
132- if err := ds .podResyncAll (ctx , client ); err != nil {
132+ if err := ds .podResyncAll (ctx , reader ); err != nil {
133133 return fmt .Errorf ("failed to update pods according to the pool selector - %w" , err )
134134 }
135135 }
@@ -182,12 +182,12 @@ func (ds *datastore) ModelSetIfOlder(infModel *v1alpha2.InferenceModel) bool {
182182 return true
183183}
184184
185- func (ds * datastore ) ModelResync (ctx context.Context , c client.Client , modelName string ) (bool , error ) {
185+ func (ds * datastore ) ModelResync (ctx context.Context , reader client.Reader , modelName string ) (bool , error ) {
186186 ds .poolAndModelsMu .Lock ()
187187 defer ds .poolAndModelsMu .Unlock ()
188188
189189 var models v1alpha2.InferenceModelList
190- if err := c .List (ctx , & models , client.MatchingFields {ModelNameIndexKey : modelName }, client .InNamespace (ds .pool .Namespace )); err != nil {
190+ if err := reader .List (ctx , & models , client.MatchingFields {ModelNameIndexKey : modelName }, client .InNamespace (ds .pool .Namespace )); err != nil {
191191 return false , fmt .Errorf ("listing models that match the modelName %s: %w" , modelName , err )
192192 }
193193 if len (models .Items ) == 0 {
@@ -288,10 +288,10 @@ func (ds *datastore) PodDelete(namespacedName types.NamespacedName) {
288288 }
289289}
290290
291- func (ds * datastore ) podResyncAll (ctx context.Context , ctrlClient client.Client ) error {
291+ func (ds * datastore ) podResyncAll (ctx context.Context , reader client.Reader ) error {
292292 logger := log .FromContext (ctx )
293293 podList := & corev1.PodList {}
294- if err := ctrlClient .List (ctx , podList , & client.ListOptions {
294+ if err := reader .List (ctx , podList , & client.ListOptions {
295295 LabelSelector : selectorFromInferencePoolSelector (ds .pool .Spec .Selector ),
296296 Namespace : ds .pool .Namespace ,
297297 }); err != nil {
0 commit comments