From fffe3f0b889e8e84f24ce1f4c6a618b274046ef7 Mon Sep 17 00:00:00 2001 From: Akhil Rane Date: Fri, 22 May 2020 19:07:30 -0400 Subject: [PATCH] Remove WaitGroup for MachineSet controller deletion requests This commit removes the WaitGroup for MachineSet controller deletion requests. It was added around v1alpha1 timeframe because Delete at that time was blocking. Today, these Delete calls can be done sequentially because they return right away and don't have to wait for the delete to finish. --- controllers/machineset_controller.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/controllers/machineset_controller.go b/controllers/machineset_controller.go index 2d3b160890ce..acc5f5086697 100644 --- a/controllers/machineset_controller.go +++ b/controllers/machineset_controller.go @@ -20,7 +20,6 @@ import ( "context" "fmt" "strings" - "sync" "time" "github.com/go-logr/logr" @@ -382,11 +381,8 @@ func (r *MachineSetReconciler) syncReplicas(ctx context.Context, ms *clusterv1.M machinesToDelete := getMachinesToDeletePrioritized(machines, diff, deletePriorityFunc) errCh := make(chan error, diff) - var wg sync.WaitGroup - wg.Add(diff) for _, machine := range machinesToDelete { go func(targetMachine *clusterv1.Machine) { - defer wg.Done() err := r.Client.Delete(context.Background(), targetMachine) if err != nil { logger.Error(err, "Unable to delete Machine", "machine", targetMachine.Name) @@ -397,7 +393,6 @@ func (r *MachineSetReconciler) syncReplicas(ctx context.Context, ms *clusterv1.M r.recorder.Eventf(ms, corev1.EventTypeNormal, "SuccessfulDelete", "Deleted machine %q", targetMachine.Name) }(machine) } - wg.Wait() close(errCh) var errs []error