Skip to content

Commit 28c3d73

Browse files
authored
Filter inference objectives based on inference pool group (#1306)
* filter inference objective based on inference pool group * update eventPredicate * Fix e2e test by explicitly specifying inference pool group * fix unit test * minor changes to unit test
1 parent f241560 commit 28c3d73

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

pkg/epp/controller/inferenceobjective_reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (c *InferenceObjectiveReconciler) Reconcile(ctx context.Context, req ctrl.R
5454
notFound = true
5555
}
5656

57-
if notFound || !infObjective.DeletionTimestamp.IsZero() || infObjective.Spec.PoolRef.Name != v1alpha2.ObjectName(c.PoolGKNN.Name) {
57+
if notFound || !infObjective.DeletionTimestamp.IsZero() || infObjective.Spec.PoolRef.Name != v1alpha2.ObjectName(c.PoolGKNN.Name) || infObjective.Spec.PoolRef.Group != v1alpha2.Group(c.PoolGKNN.Group) {
5858
// InferenceObjective object got deleted or changed the referenced pool.
5959
c.Datastore.ObjectiveDelete(req.NamespacedName)
6060
return ctrl.Result{}, nil
@@ -83,5 +83,5 @@ func (c *InferenceObjectiveReconciler) SetupWithManager(ctx context.Context, mgr
8383
}
8484

8585
func (c *InferenceObjectiveReconciler) eventPredicate(infObjective *v1alpha2.InferenceObjective) bool {
86-
return string(infObjective.Spec.PoolRef.Name) == c.PoolGKNN.Name
86+
return string(infObjective.Spec.PoolRef.Name) == c.PoolGKNN.Name && string(infObjective.Spec.PoolRef.Group) == c.PoolGKNN.Group
8787
}

pkg/epp/controller/inferenceobjective_reconciler_test.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,37 @@ var (
4545
Namespace(pool.Namespace).
4646
Criticality(v1alpha2.Standard).
4747
CreationTimestamp(metav1.Unix(1000, 0)).
48-
PoolName(pool.Name).ObjRef()
48+
PoolName(pool.Name).
49+
PoolGroup("inference.networking.k8s.io").ObjRef()
4950
infObjective1Pool2 = utiltest.MakeInferenceObjective(infObjective1.Name).
5051
Namespace(infObjective1.Namespace).
5152
Criticality(*infObjective1.Spec.Criticality).
5253
CreationTimestamp(metav1.Unix(1001, 0)).
53-
PoolName("test-pool2").ObjRef()
54+
PoolName("test-pool2").
55+
PoolGroup("inference.networking.k8s.io").ObjRef()
5456
infObjective1Critical = utiltest.MakeInferenceObjective(infObjective1.Name).
5557
Namespace(infObjective1.Namespace).
5658
Criticality(v1alpha2.Critical).
5759
CreationTimestamp(metav1.Unix(1003, 0)).
58-
PoolName(pool.Name).ObjRef()
60+
PoolName(pool.Name).
61+
PoolGroup("inference.networking.k8s.io").ObjRef()
5962
infObjective1Deleted = utiltest.MakeInferenceObjective(infObjective1.Name).
6063
Namespace(infObjective1.Namespace).
6164
CreationTimestamp(metav1.Unix(1004, 0)).
6265
DeletionTimestamp().
63-
PoolName(pool.Name).ObjRef()
64-
66+
PoolName(pool.Name).
67+
PoolGroup("inference.networking.k8s.io").ObjRef()
68+
infObjective1DiffGroup = utiltest.MakeInferenceObjective(infObjective1.Name).
69+
Namespace(pool.Namespace).
70+
Criticality(v1alpha2.Standard).
71+
CreationTimestamp(metav1.Unix(1005, 0)).
72+
PoolName(pool.Name).
73+
PoolGroup("inference.networking.x-k8s.io").ObjRef()
6574
infObjective2 = utiltest.MakeInferenceObjective("model2").
6675
Namespace(pool.Namespace).
6776
CreationTimestamp(metav1.Unix(1000, 0)).
68-
PoolName(pool.Name).ObjRef()
77+
PoolName(pool.Name).
78+
PoolGroup("inference.networking.k8s.io").ObjRef()
6979
)
7080

7181
func TestInferenceObjectiveReconciler(t *testing.T) {
@@ -119,6 +129,17 @@ func TestInferenceObjectiveReconciler(t *testing.T) {
119129
objective: infObjective2,
120130
wantObjectives: []*v1alpha2.InferenceObjective{infObjective1, infObjective2},
121131
},
132+
{
133+
name: "Objective deleted due to group mismatch for the inference pool",
134+
objectivessInStore: []*v1alpha2.InferenceObjective{infObjective1},
135+
objective: infObjective1DiffGroup,
136+
wantObjectives: []*v1alpha2.InferenceObjective{},
137+
},
138+
{
139+
name: "Objective ignored due to group mismatch for the inference pool",
140+
objective: infObjective1DiffGroup,
141+
wantObjectives: []*v1alpha2.InferenceObjective{},
142+
},
122143
}
123144
for _, test := range tests {
124145
t.Run(test.name, func(t *testing.T) {
@@ -134,7 +155,6 @@ func TestInferenceObjectiveReconciler(t *testing.T) {
134155
for _, m := range test.objectivesInAPIServer {
135156
initObjs = append(initObjs, m)
136157
}
137-
138158
fakeClient := fake.NewClientBuilder().
139159
WithScheme(scheme).
140160
WithObjects(initObjs...).

pkg/epp/util/testing/wrappers.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ func (m *InferenceObjectiveWrapper) TargetModel(modelName string) *InferenceObje
142142
}
143143

144144
func (m *InferenceObjectiveWrapper) PoolName(poolName string) *InferenceObjectiveWrapper {
145-
m.Spec.PoolRef = v1alpha2.PoolObjectReference{Name: v1alpha2.ObjectName(poolName)}
145+
m.Spec.PoolRef.Name = v1alpha2.ObjectName(poolName)
146+
return m
147+
}
148+
149+
func (m *InferenceObjectiveWrapper) PoolGroup(poolGroup string) *InferenceObjectiveWrapper {
150+
m.Spec.PoolRef.Group = v1alpha2.Group(poolGroup)
146151
return m
147152
}
148153

@@ -175,6 +180,10 @@ func MakeInferencePool(name string) *InferencePoolWrapper {
175180
ObjectMeta: metav1.ObjectMeta{
176181
Name: name,
177182
},
183+
TypeMeta: metav1.TypeMeta{
184+
APIVersion: "inference.networking.k8s.io/v1",
185+
Kind: "InferencePool",
186+
},
178187
Spec: v1.InferencePoolSpec{},
179188
},
180189
}

test/testdata/inferencepool-with-model-hermetic.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ spec:
1919
criticality: Critical
2020
poolRef:
2121
name: vllm-llama3-8b-instruct-pool
22+
group: inference.networking.k8s.io
2223
targetModels:
2324
- name: sql-lora-1fdg2
2425
weight: 100
@@ -31,6 +32,7 @@ metadata:
3132
spec:
3233
poolRef:
3334
name: vllm-llama3-8b-instruct-pool
35+
group: inference.networking.k8s.io
3436
targetModels:
3537
- name: sql-lora-1fdg3
3638
weight: 100
@@ -44,6 +46,7 @@ spec:
4446
criticality: Critical
4547
poolRef:
4648
name: vllm-llama3-8b-instruct-pool
49+
group: inference.networking.k8s.io
4750
targetModels:
4851
- name: my-model-12345
4952
weight: 100
@@ -56,4 +59,5 @@ metadata:
5659
spec:
5760
criticality: Critical
5861
poolRef:
59-
name: vllm-llama3-8b-instruct-pool
62+
name: vllm-llama3-8b-instruct-pool
63+
group: inference.networking.k8s.io

0 commit comments

Comments
 (0)