@@ -520,54 +520,6 @@ func (ctl *controller) createLaunchers(ctx context.Context, node corev1.Node, ke
520520 return nil
521521}
522522
523- // deleteExcessLaunchers deletes the specified number of launcher pods
524- func (ctl * controller ) deleteExcessLaunchers (ctx context.Context , launchers []* corev1.Pod , count int ) error {
525- logger := klog .FromContext (ctx )
526-
527- deletedCount := 0
528- for i := 0 ; i < count && i < len (launchers ); i ++ {
529- pod := launchers [len (launchers )- 1 - i ]
530- isBound , requesterPodName := ctl .isLauncherBoundToServerRequestingPod (pod )
531- if isBound {
532- logger .V (5 ).Info ("Skipping deletion of launcher pod as it is bound to a server-requesting pod" ,
533- "pod" , pod .Name , "server-requesting pod" , requesterPodName )
534- continue
535- }
536-
537- if err := ctl .coreclient .Pods (pod .Namespace ).Delete (ctx , pod .Name , metav1.DeleteOptions {
538- Preconditions : & metav1.Preconditions {
539- ResourceVersion : & pod .ResourceVersion ,
540- },
541- }); err != nil {
542- if apierrors .IsNotFound (err ) {
543- logger .Info ("Launcher pod already deleted" , "pod" , pod .Name )
544- deletedCount ++ // Count as deletion target achieved
545- continue
546- }
547- if apierrors .IsConflict (err ) {
548- logger .Info ("Launcher pod version conflict, skipping deletion" ,
549- "pod" , pod .Name , "error" , err )
550- continue
551- }
552- return fmt .Errorf ("failed to delete launcher pod %s: %w" , pod .Name , err )
553- }
554- logger .Info ("Deleted launcher pod" , "pod" , pod .Name )
555- deletedCount ++
556- }
557-
558- if deletedCount < count {
559- logger .Info ("Fewer launcher pods were deleted than requested due to bound pods or concurrent changes" ,
560- "requested" , count ,
561- "deleted" , deletedCount ,
562- "skipped" , count - deletedCount )
563- } else {
564- logger .Info ("Deleted unbound launcher pods" ,
565- "deleted" , deletedCount )
566- }
567-
568- return nil
569- }
570-
571523// isLauncherBoundToServerRequestingPod checks if the launcher pod is bound to any server-requesting pod
572524func (ctl * controller ) isLauncherBoundToServerRequestingPod (launcherPod * corev1.Pod ) (bool , string ) {
573525 // Check if the launcher pod has annotations indicating assignment to a server-requesting pod
0 commit comments