Commit e1e05913 authored by Ward Loos's avatar Ward Loos

Don't reset global timeout on each for loop iteration

parent be43b7cc
...@@ -610,6 +610,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g ...@@ -610,6 +610,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g
} else { } else {
globalTimeout = o.Timeout globalTimeout = o.Timeout
} }
globalTimeoutCh := time.After(globalTimeout)
for { for {
select { select {
case err := <-errCh: case err := <-errCh:
...@@ -619,7 +620,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g ...@@ -619,7 +620,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g
if doneCount == len(pods) { if doneCount == len(pods) {
return nil return nil
} }
case <-time.After(globalTimeout): case <-globalTimeoutCh:
return fmt.Errorf("Drain did not complete within %v", globalTimeout) return fmt.Errorf("Drain did not complete within %v", globalTimeout)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment