Unverified Commit e1cc1fce authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #64378 from wrdls/evict-timeout

Automatic merge from submit-queue (batch tested with PRs 64252, 64307, 64163, 64378, 64179). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix kubectl drain --timeout option when eviction is used **What this PR does / why we need it**: Timeout option of kubectl drain command is currently broken when using eviction to delete pods. A new timer is made on each for loop iteration which means it gets reset each time a pod is evicted. **Release note**: ```release-note Fix kubectl drain --timeout option when eviction is used. ``` @kubernetes/sig-cli-pr-reviews
parents 6559b98f e1e05913
...@@ -611,6 +611,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g ...@@ -611,6 +611,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:
...@@ -620,7 +621,7 @@ func (o *DrainOptions) evictPods(pods []corev1.Pod, policyGroupVersion string, g ...@@ -620,7 +621,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