From 93f62dad6c58bb41c396c48f54c0a73830779599 Mon Sep 17 00:00:00 2001 From: Ryan Phillips Date: Fri, 20 Mar 2020 14:43:33 -0500 Subject: [PATCH] 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 --- staging/src/k8s.io/kubectl/pkg/drain/drain.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/staging/src/k8s.io/kubectl/pkg/drain/drain.go b/staging/src/k8s.io/kubectl/pkg/drain/drain.go index a6657d1a714..d613c821045 100644 --- a/staging/src/k8s.io/kubectl/pkg/drain/drain.go +++ b/staging/src/k8s.io/kubectl/pkg/drain/drain.go @@ -277,6 +277,9 @@ func (d *Helper) evictPods(pods []corev1.Pod, policyGroupVersion string, getPodF } else if apierrors.IsTooManyRequests(err) { fmt.Fprintf(d.ErrOut, "error when evicting pods/%q -n %q (will retry after 5s): %v\n", pod.Name, pod.Namespace, err) time.Sleep(5 * time.Second) + } else if apierrors.IsForbidden(err) { + // an eviction request in a deleting namespace will throw a forbidden error + break } else { returnCh <- fmt.Errorf("error when evicting pods/%q -n %q: %v", pod.Name, pod.Namespace, err) return