update drain message to include namespace for pod in kubectl get compatible format

This commit is contained in:
David Eads 2020-08-26 11:58:14 -04:00
parent 4db3a096ce
commit 9655953000

View File

@ -264,7 +264,7 @@ func (d *Helper) evictPods(pods []corev1.Pod, policyGroupVersion string, getPodF
select { select {
case <-ctx.Done(): case <-ctx.Done():
// return here or we'll leak a goroutine. // return here or we'll leak a goroutine.
returnCh <- fmt.Errorf("error when evicting pod %q: global timeout reached: %v", pod.Name, globalTimeout) returnCh <- fmt.Errorf("error when evicting pods/%q -n %q: global timeout reached: %v", pod.Name, pod.Namespace, globalTimeout)
return return
default: default:
} }
@ -275,10 +275,10 @@ func (d *Helper) evictPods(pods []corev1.Pod, policyGroupVersion string, getPodF
returnCh <- nil returnCh <- nil
return return
} else if apierrors.IsTooManyRequests(err) { } else if apierrors.IsTooManyRequests(err) {
fmt.Fprintf(d.ErrOut, "error when evicting pod %q (will retry after 5s): %v\n", pod.Name, 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) time.Sleep(5 * time.Second)
} else { } else {
returnCh <- fmt.Errorf("error when evicting pod %q: %v", pod.Name, err) returnCh <- fmt.Errorf("error when evicting pods/%q -n %q: %v", pod.Name, pod.Namespace, err)
return return
} }
} }