Skip to content

Commit 5ccd2ff

Browse files
committed
embedding ready status into update so non-ready pods are deleted
1 parent 4fd4c94 commit 5ccd2ff

File tree

2 files changed

+79
-4
lines changed

2 files changed

+79
-4
lines changed

pkg/ext-proc/backend/pod_reconciler.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ func (c *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
3737
return ctrl.Result{}, err
3838
}
3939

40-
if !podIsReady(pod) {
41-
return ctrl.Result{RequeueAfter: time.Second * 5}, nil
42-
}
4340
c.updateDatastore(pod, inferencePool)
4441

4542
return ctrl.Result{}, nil
@@ -56,7 +53,7 @@ func (c *PodReconciler) updateDatastore(k8sPod *corev1.Pod, inferencePool *v1alp
5653
Name: k8sPod.Name,
5754
Address: k8sPod.Status.PodIP + ":" + strconv.Itoa(int(inferencePool.Spec.TargetPortNumber)),
5855
}
59-
if !c.Datastore.LabelsMatch(k8sPod.ObjectMeta.Labels) {
56+
if !c.Datastore.LabelsMatch(k8sPod.ObjectMeta.Labels) || !podIsReady(k8sPod) {
6057
c.Datastore.pods.Delete(pod)
6158
} else {
6259
c.Datastore.pods.Store(pod, true)

pkg/ext-proc/backend/pod_reconciler_test.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,48 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
4343
"some-key": "some-val",
4444
},
4545
},
46+
Status: corev1.PodStatus{
47+
Conditions: []corev1.PodCondition{
48+
{
49+
Type: corev1.PodReady,
50+
Status: corev1.ConditionTrue,
51+
},
52+
},
53+
},
4654
},
4755
wantPods: []string{basePod1.Name, basePod2.Name, basePod3.Name},
4856
},
57+
{
58+
name: "New pod, not ready, valid selector",
59+
datastore: &K8sDatastore{
60+
pods: populateMap(basePod1, basePod2),
61+
inferencePool: &v1alpha1.InferencePool{
62+
Spec: v1alpha1.InferencePoolSpec{
63+
TargetPortNumber: int32(8000),
64+
Selector: map[v1alpha1.LabelKey]v1alpha1.LabelValue{
65+
"some-key": "some-val",
66+
},
67+
},
68+
},
69+
},
70+
incomingPod: &corev1.Pod{
71+
ObjectMeta: metav1.ObjectMeta{
72+
Name: "pod3",
73+
Labels: map[string]string{
74+
"some-key": "some-val",
75+
},
76+
},
77+
Status: corev1.PodStatus{
78+
Conditions: []corev1.PodCondition{
79+
{
80+
Type: corev1.PodReady,
81+
Status: corev1.ConditionFalse,
82+
},
83+
},
84+
},
85+
},
86+
wantPods: []string{basePod1.Name, basePod2.Name},
87+
},
4988
{
5089
name: "Remove pod that does not match selector",
5190
datastore: &K8sDatastore{
@@ -66,6 +105,45 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
66105
"some-wrong-key": "some-val",
67106
},
68107
},
108+
Status: corev1.PodStatus{
109+
Conditions: []corev1.PodCondition{
110+
{
111+
Type: corev1.PodReady,
112+
Status: corev1.ConditionTrue,
113+
},
114+
},
115+
},
116+
},
117+
wantPods: []string{basePod2.Name},
118+
},
119+
{
120+
name: "Remove pod that is not ready",
121+
datastore: &K8sDatastore{
122+
pods: populateMap(basePod1, basePod2),
123+
inferencePool: &v1alpha1.InferencePool{
124+
Spec: v1alpha1.InferencePoolSpec{
125+
TargetPortNumber: int32(8000),
126+
Selector: map[v1alpha1.LabelKey]v1alpha1.LabelValue{
127+
"some-key": "some-val",
128+
},
129+
},
130+
},
131+
},
132+
incomingPod: &corev1.Pod{
133+
ObjectMeta: metav1.ObjectMeta{
134+
Name: "pod1",
135+
Labels: map[string]string{
136+
"some-wrong-key": "some-val",
137+
},
138+
},
139+
Status: corev1.PodStatus{
140+
Conditions: []corev1.PodCondition{
141+
{
142+
Type: corev1.PodReady,
143+
Status: corev1.ConditionFalse,
144+
},
145+
},
146+
},
69147
},
70148
wantPods: []string{basePod2.Name},
71149
},

0 commit comments

Comments
 (0)