Skip to content

Commit 225f6b1

Browse files
committed
Addressed more comments
1 parent 6159313 commit 225f6b1

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

pkg/ext-proc/backend/datastore.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Datastore interface {
3131

3232
// PodMetrics operations
3333
PodUpdateOrAddIfNotExist(pod *corev1.Pod) bool
34-
PodUpdateMetricsIfExist(pm *PodMetrics) bool
34+
PodUpdateMetricsIfExist(namespacedName types.NamespacedName, m *Metrics) bool
3535
PodGet(namespacedName types.NamespacedName) (*PodMetrics, bool)
3636
PodDelete(namespacedName types.NamespacedName)
3737
PodResyncAll(ctx context.Context, ctrlClient client.Client)
@@ -115,10 +115,10 @@ func (ds *datastore) ModelDelete(modelName string) {
115115
}
116116

117117
// /// Pods/endpoints APIs ///
118-
func (ds *datastore) PodUpdateMetricsIfExist(pm *PodMetrics) bool {
119-
if val, ok := ds.pods.Load(pm.NamespacedName); ok {
118+
func (ds *datastore) PodUpdateMetricsIfExist(namespacedName types.NamespacedName, m *Metrics) bool {
119+
if val, ok := ds.pods.Load(namespacedName); ok {
120120
existing := val.(*PodMetrics)
121-
existing.Metrics = pm.Metrics
121+
existing.Metrics = *m
122122
return true
123123
}
124124
return false

pkg/ext-proc/backend/inferencepool_reconciler.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"k8s.io/apimachinery/pkg/runtime"
99
"k8s.io/apimachinery/pkg/types"
1010
"k8s.io/client-go/tools/record"
11-
klog "k8s.io/klog/v2"
1211
ctrl "sigs.k8s.io/controller-runtime"
1312
"sigs.k8s.io/controller-runtime/pkg/client"
1413
"sigs.k8s.io/controller-runtime/pkg/log"
@@ -59,10 +58,10 @@ func (c *InferencePoolReconciler) Reconcile(ctx context.Context, req ctrl.Reques
5958

6059
func (c *InferencePoolReconciler) updateDatastore(ctx context.Context, newPool *v1alpha1.InferencePool) {
6160
logger := log.FromContext(ctx)
62-
oldPool, _ := c.Datastore.PoolGet()
61+
oldPool, err := c.Datastore.PoolGet()
6362
c.Datastore.PoolSet(newPool)
64-
if oldPool == nil || !reflect.DeepEqual(newPool.Spec.Selector, oldPool.Spec.Selector) {
65-
logger.V(logutil.DEFAULT).Info("Updating inference pool endpoints", "target", klog.KMetadata(&newPool.ObjectMeta))
63+
if err != nil || !reflect.DeepEqual(newPool.Spec.Selector, oldPool.Spec.Selector) {
64+
logger.V(logutil.DEFAULT).Info("Updating inference pool endpoints", "selector", newPool.Spec.Selector)
6665
c.Datastore.PodResyncAll(ctx, c.Client)
6766
}
6867
}

pkg/ext-proc/backend/provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (p *Provider) refreshMetricsOnce(logger logr.Logger) error {
109109
errCh <- fmt.Errorf("failed to parse metrics from %s: %v", existing.NamespacedName, err)
110110
return
111111
}
112-
p.datastore.PodUpdateMetricsIfExist(updated)
112+
p.datastore.PodUpdateMetricsIfExist(updated.NamespacedName, &updated.Metrics)
113113
loggerTrace.Info("Updated metrics for pod", "pod", updated.NamespacedName, "metrics", updated.Metrics)
114114
}()
115115
return true

pkg/ext-proc/test/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func StartExtProc(
4444
IP(pm.Address).
4545
Obj()
4646
datastore.PodUpdateOrAddIfNotExist(&pod)
47-
datastore.PodUpdateMetricsIfExist(pm)
47+
datastore.PodUpdateMetricsIfExist(pm.NamespacedName, &pm.Metrics)
4848
}
4949
pp := backend.NewProvider(pmc, datastore)
5050
if err := pp.Init(ctx, refreshMetricsInterval, refreshPrometheusMetricsInterval); err != nil {

0 commit comments

Comments
 (0)