@@ -227,10 +227,6 @@ func (allocator *defaultAllocator) Schedule(ctx context.Context, spec *AllocSpec
227227 if spec .RecyclingPods .Has (pod .Name ) {
228228 continue
229229 }
230- // Exclude pods that are restarting (have recycle-meta annotation)
231- if isRecycling (pod ) {
232- continue
233- }
234230 if pod .Status .Phase != corev1 .PodRunning {
235231 continue
236232 }
@@ -240,11 +236,11 @@ func (allocator *defaultAllocator) Schedule(ctx context.Context, spec *AllocSpec
240236 for podName , sandboxName := range status .PodAllocation {
241237 sandboxToPods [sandboxName ] = append (sandboxToPods [sandboxName ], podName )
242238 }
243- sandboxAlloc , dirtySandboxes , poolAllocate , err := allocator .allocate (ctx , status , sandboxToPods , availablePods , spec .Sandboxes , spec . Pods )
239+ sandboxAlloc , dirtySandboxes , poolAllocate , err := allocator .allocate (ctx , status , sandboxToPods , availablePods , spec .Sandboxes )
244240 if err != nil {
245241 log .Error (err , "allocate failed" )
246242 }
247- poolDeallocate , err := allocator .deallocate (ctx , status , sandboxToPods , spec .Sandboxes )
243+ poolDeallocate , err := allocator .deallocate (ctx , status , sandboxToPods , spec .Sandboxes , spec . RecyclingPods )
248244 if err != nil {
249245 log .Error (err , "deallocate failed" )
250246 }
@@ -284,7 +280,7 @@ func (allocator *defaultAllocator) initAllocation(ctx context.Context, spec *All
284280 return status , nil
285281}
286282
287- func (allocator * defaultAllocator ) allocate (ctx context.Context , status * AllocStatus , sandboxToPods map [string ][]string , availablePods []string , sandboxes []* sandboxv1alpha1.BatchSandbox , pods [] * corev1. Pod ) (map [string ][]string , []string , bool , error ) {
283+ func (allocator * defaultAllocator ) allocate (ctx context.Context , status * AllocStatus , sandboxToPods map [string ][]string , availablePods []string , sandboxes []* sandboxv1alpha1.BatchSandbox ) (map [string ][]string , []string , bool , error ) {
288284 errs := make ([]error , 0 )
289285 sandboxAlloc := make (map [string ][]string )
290286 dirtySandboxes := make ([]string , 0 )
@@ -366,7 +362,7 @@ func (allocator *defaultAllocator) doAllocate(ctx context.Context, status *Alloc
366362 return sandboxAlloc , remainAvailablePods , sandboxDirty , poolAllocate , nil
367363}
368364
369- func (allocator * defaultAllocator ) deallocate (ctx context.Context , status * AllocStatus , sandboxToPods map [string ][]string , sandboxes []* sandboxv1alpha1.BatchSandbox ) (bool , error ) {
365+ func (allocator * defaultAllocator ) deallocate (ctx context.Context , status * AllocStatus , sandboxToPods map [string ][]string , sandboxes []* sandboxv1alpha1.BatchSandbox , recycling sets. Set [ string ] ) (bool , error ) {
370366 log := logf .FromContext (ctx )
371367 poolDeallocate := false
372368 errs := make ([]error , 0 )
@@ -393,6 +389,9 @@ func (allocator *defaultAllocator) deallocate(ctx context.Context, status *Alloc
393389 pods := sandboxToPods [name ]
394390 log .Info ("GC deleted sandbox allocation" , "sandbox" , name , "podCount" , len (pods ))
395391 for _ , pod := range pods {
392+ if recycling .Has (pod ) {
393+ continue
394+ }
396395 delete (status .PodAllocation , pod )
397396 poolDeallocate = true
398397 }
0 commit comments