@@ -51,15 +51,15 @@ type Datastore interface {
51
51
52
52
// InferenceModel operations
53
53
ModelSetIfOlder (infModel * v1alpha2.InferenceModel ) bool
54
- ModelGet (modelName string ) ( * v1alpha2.InferenceModel , bool )
55
- ModelDelete (namespacedName types.NamespacedName ) ( * v1alpha2.InferenceModel , bool )
54
+ ModelGet (modelName string ) * v1alpha2.InferenceModel
55
+ ModelDelete (namespacedName types.NamespacedName ) * v1alpha2.InferenceModel
56
56
ModelResync (ctx context.Context , ctrlClient client.Client , modelName string ) (bool , error )
57
57
ModelGetAll () []* v1alpha2.InferenceModel
58
58
59
59
// PodMetrics operations
60
60
PodUpdateOrAddIfNotExist (pod * corev1.Pod ) bool
61
61
PodUpdateMetricsIfExist (namespacedName types.NamespacedName , m * Metrics ) bool
62
- PodGet (namespacedName types.NamespacedName ) ( * PodMetrics , bool )
62
+ PodGet (namespacedName types.NamespacedName ) * PodMetrics
63
63
PodDelete (namespacedName types.NamespacedName )
64
64
PodResyncAll (ctx context.Context , ctrlClient client.Client )
65
65
PodGetAll () []* PodMetrics
@@ -147,7 +147,6 @@ func (ds *datastore) PoolLabelsMatch(podLabels map[string]string) bool {
147
147
return poolSelector .Matches (podSet )
148
148
}
149
149
150
- // /// InferenceModel APIs ///
151
150
func (ds * datastore ) ModelSetIfOlder (infModel * v1alpha2.InferenceModel ) bool {
152
151
ds .poolAndModelsMu .Lock ()
153
152
defer ds .poolAndModelsMu .Unlock ()
@@ -199,23 +198,22 @@ func (ds *datastore) ModelResync(ctx context.Context, c client.Client, modelName
199
198
return true , nil
200
199
}
201
200
202
- func (ds * datastore ) ModelGet (modelName string ) ( * v1alpha2.InferenceModel , bool ) {
201
+ func (ds * datastore ) ModelGet (modelName string ) * v1alpha2.InferenceModel {
203
202
ds .poolAndModelsMu .RLock ()
204
203
defer ds .poolAndModelsMu .RUnlock ()
205
- m , exists := ds .models [modelName ]
206
- return m , exists
204
+ return ds .models [modelName ]
207
205
}
208
206
209
- func (ds * datastore ) ModelDelete (namespacedName types.NamespacedName ) ( * v1alpha2.InferenceModel , bool ) {
207
+ func (ds * datastore ) ModelDelete (namespacedName types.NamespacedName ) * v1alpha2.InferenceModel {
210
208
ds .poolAndModelsMu .Lock ()
211
209
defer ds .poolAndModelsMu .Unlock ()
212
210
for _ , m := range ds .models {
213
211
if m .Name == namespacedName .Name && m .Namespace == namespacedName .Namespace {
214
212
delete (ds .models , m .Spec .ModelName )
215
- return m , true
213
+ return m
216
214
}
217
215
}
218
- return nil , false
216
+ return nil
219
217
}
220
218
221
219
func (ds * datastore ) ModelGetAll () []* v1alpha2.InferenceModel {
@@ -238,12 +236,12 @@ func (ds *datastore) PodUpdateMetricsIfExist(namespacedName types.NamespacedName
238
236
return false
239
237
}
240
238
241
- func (ds * datastore ) PodGet (namespacedName types.NamespacedName ) ( * PodMetrics , bool ) {
239
+ func (ds * datastore ) PodGet (namespacedName types.NamespacedName ) * PodMetrics {
242
240
val , ok := ds .pods .Load (namespacedName )
243
241
if ok {
244
- return val .(* PodMetrics ), true
242
+ return val .(* PodMetrics )
245
243
}
246
- return nil , false
244
+ return nil
247
245
}
248
246
249
247
func (ds * datastore ) PodGetAll () []* PodMetrics {
@@ -311,7 +309,7 @@ func (ds *datastore) PodResyncAll(ctx context.Context, ctrlClient client.Client)
311
309
}
312
310
}
313
311
314
- // Remove pods that don't exist or not ready any more.
312
+ // Remove pods that don't belong to the pool or not ready any more.
315
313
deleteFn := func (k , v any ) bool {
316
314
pm := v .(* PodMetrics )
317
315
if exist := activePods [pm .NamespacedName .Name ]; ! exist {
0 commit comments