Skip to content

Commit

Permalink
Do not spin forever if kubectl drain races with other removal
Browse files Browse the repository at this point in the history
In kubernetes#47450 we stopped
returning an error if a pod disappeared before we could remove it.
Instead we just continue to spin forever. Return "success" if a pod
disappeared before we actually removed it.

https://bugzilla.redhat.com/1473777
bug 1473777
  • Loading branch information
eparis committed Jul 22, 2017
1 parent 72b2a03 commit 7c531ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/kubectl/cmd/drain.go
Expand Up @@ -495,9 +495,12 @@ func (o *DrainOptions) evictPods(pods []api.Pod, policyGroupVersion string, getP
err = o.evictPod(pod, policyGroupVersion)
if err == nil {
break
} else if apierrors.IsNotFound(err) {
doneCh <- true
return
} else if apierrors.IsTooManyRequests(err) {
time.Sleep(5 * time.Second)
} else if !apierrors.IsNotFound(err) {
} else {
errCh <- fmt.Errorf("error when evicting pod %q: %v", pod.Name, err)
return
}
Expand Down

0 comments on commit 7c531ec

Please sign in to comment.