@@ -259,6 +259,54 @@ func TestSchedule(t *testing.T) {
259259 PodSupplement : 0 ,
260260 },
261261 },
262+ {
263+ name : "released pod does not block second re-allocation" ,
264+ spec : & AllocSpec {
265+ Pods : []* corev1.Pod {
266+ // pod1 was previously allocated and released (recycled).
267+ // pod2 was the replacement but is now also deleted.
268+ // pod3 is a new available pod.
269+ {ObjectMeta : metav1.ObjectMeta {Name : "pod3" }, Status : corev1.PodStatus {Phase : corev1 .PodRunning , Conditions : []corev1.PodCondition {{Type : corev1 .PodReady , Status : corev1 .ConditionTrue }}}},
270+ },
271+ Pool : & sandboxv1alpha1.Pool {ObjectMeta : metav1.ObjectMeta {Name : "pool1" }},
272+ Sandboxes : []* sandboxv1alpha1.BatchSandbox {
273+ {ObjectMeta : metav1.ObjectMeta {Name : "sbx1" }, Spec : sandboxv1alpha1.BatchSandboxSpec {Replicas : & replica1 }},
274+ },
275+ },
276+ poolAlloc : & PoolAllocation {PodAllocation : map [string ]string {"pod1" : "sbx1" , "pod2" : "sbx1" }},
277+ sandboxAllocs : map [string ]* SandboxAllocation {"sbx1" : {Pods : []string {"pod1" , "pod2" }}},
278+ releases : map [string ]* AllocationRelease {"sbx1" : {Pods : []string {}}},
279+ released : map [string ]* AllocationReleased {"sbx1" : {Pods : []string {"pod1" }}},
280+ wantAction : & algorithm.AllocAction {
281+ ToAllocate : map [string ][]string {"sbx1" : {"pod3" }},
282+ ToRelease : map [string ][]string {"sbx1" : {"pod2" }},
283+ PodSupplement : 0 ,
284+ },
285+ },
286+ {
287+ name : "terminal pod (Failed) triggers re-allocation" ,
288+ spec : & AllocSpec {
289+ Pods : []* corev1.Pod {
290+ // pod1 exists but is in Failed state — should not count as live.
291+ {ObjectMeta : metav1.ObjectMeta {Name : "pod1" }, Status : corev1.PodStatus {Phase : corev1 .PodFailed }},
292+ // pod2 is ready and available.
293+ {ObjectMeta : metav1.ObjectMeta {Name : "pod2" }, Status : corev1.PodStatus {Phase : corev1 .PodRunning , Conditions : []corev1.PodCondition {{Type : corev1 .PodReady , Status : corev1 .ConditionTrue }}}},
294+ },
295+ Pool : & sandboxv1alpha1.Pool {ObjectMeta : metav1.ObjectMeta {Name : "pool1" }},
296+ Sandboxes : []* sandboxv1alpha1.BatchSandbox {
297+ {ObjectMeta : metav1.ObjectMeta {Name : "sbx1" }, Spec : sandboxv1alpha1.BatchSandboxSpec {Replicas : & replica1 }},
298+ },
299+ },
300+ poolAlloc : & PoolAllocation {PodAllocation : map [string ]string {"pod1" : "sbx1" }},
301+ sandboxAllocs : map [string ]* SandboxAllocation {"sbx1" : {Pods : []string {"pod1" }}},
302+ releases : map [string ]* AllocationRelease {"sbx1" : {Pods : []string {}}},
303+ released : map [string ]* AllocationReleased {"sbx1" : {Pods : []string {}}},
304+ wantAction : & algorithm.AllocAction {
305+ ToAllocate : map [string ][]string {"sbx1" : {"pod2" }},
306+ ToRelease : map [string ][]string {"sbx1" : {"pod1" }},
307+ PodSupplement : 0 ,
308+ },
309+ },
262310 {
263311 name : "orphan sandbox - pods in store but sandbox no longer in spec" ,
264312 spec : & AllocSpec {
0 commit comments