Skip to content

Commit 93f62da

Browse files
rphillipsmichaelgugino
authored andcommitted
drain: eviction creates in a deleting namespace will throw a forbidden error
we can safely ignore this error since a deleting namespace will delete all pods
1 parent d159ae3 commit 93f62da

File tree

1 file changed

+3
-0
lines changed
  • staging/src/k8s.io/kubectl/pkg/drain

1 file changed

+3
-0
lines changed

staging/src/k8s.io/kubectl/pkg/drain/drain.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ func (d *Helper) evictPods(pods []corev1.Pod, policyGroupVersion string, getPodF
277277
} else if apierrors.IsTooManyRequests(err) {
278278
fmt.Fprintf(d.ErrOut, "error when evicting pods/%q -n %q (will retry after 5s): %v\n", pod.Name, pod.Namespace, err)
279279
time.Sleep(5 * time.Second)
280+
} else if apierrors.IsForbidden(err) {
281+
// an eviction request in a deleting namespace will throw a forbidden error
282+
break
280283
} else {
281284
returnCh <- fmt.Errorf("error when evicting pods/%q -n %q: %v", pod.Name, pod.Namespace, err)
282285
return

0 commit comments

Comments
 (0)