UPSTREAM: 64378: Don't reset global timeout on each for loop iteration
@@ -610,6 +610,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g
} else {
globalTimeout = o.Timeout
}
+ globalTimeoutCh := time.After(globalTimeout)
for {
select {
case err := <-errCh:
@@ -619,7 +620,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g
if doneCount == len(pods) {
return nil
}
- case <-time.After(globalTimeout):
+ case <-globalTimeoutCh:
return fmt.Errorf("Drain did not complete within %v", globalTimeout)
}
}
