@@ -379,24 +379,19 @@ func (h *DrainNodeHandler) waitNodePodsTerminated(ctx context.Context, log logru
379379 return true , fmt .Errorf ("listing %q pods to be terminated: %w" , node .Name , err )
380380 }
381381
382- remainingPods := len (pods )
383- if len (podsToIgnore ) > 0 {
384- for i := range pods {
385- _ , shouldIgnore := podsToIgnoreLookup [fmt .Sprintf ("%s/%s" , pods [i ].Namespace , pods [i ].Name )]
386- if shouldIgnore {
387- remainingPods --
388- }
389- }
390- }
391- remainingPodsList := lo .Filter (pods , func (p v1.Pod , _ int ) bool {
392- _ , shouldIgnore := podsToIgnoreLookup [fmt .Sprintf ("%s/%s" , p .Namespace , p .Name )]
393- return ! shouldIgnore
394- })
395- podsNames := lo .Map (remainingPodsList , func (p v1.Pod , _ int ) string {
382+ podsNames := lo .Map (pods , func (p v1.Pod , _ int ) string {
396383 return fmt .Sprintf ("%s/%s" , p .Namespace , p .Name )
397384 })
398- if remainingPods > 0 {
399- return true , fmt .Errorf ("waiting for %d pods (%v) to be terminated on node %v" , remainingPods , podsNames , node .Name )
385+
386+ remainingPodsList := podsNames
387+ if len (podsToIgnore ) > 0 {
388+ remainingPodsList = lo .Filter (remainingPodsList , func (podName string , _ int ) bool {
389+ _ , ok := podsToIgnoreLookup [podName ]
390+ return ! ok
391+ })
392+ }
393+ if remainingPods := len (remainingPodsList ); remainingPods > 0 {
394+ return true , fmt .Errorf ("waiting for %d pods (%v) to be terminated on node %v" , remainingPods , remainingPodsList , node .Name )
400395 }
401396 return false , nil
402397 },
0 commit comments