mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
When running kubectl drain
in dry-run, list warnings and pods that would be deleted.
This commit is contained in:
parent
833f585104
commit
909300b8be
@ -288,11 +288,7 @@ func (o *DrainCmdOptions) RunDrain() error {
|
||||
var fatal error
|
||||
|
||||
for _, info := range o.nodeInfos {
|
||||
var err error
|
||||
if !o.drainer.DryRun {
|
||||
err = o.deleteOrEvictPodsSimple(info)
|
||||
}
|
||||
if err == nil || o.drainer.DryRun {
|
||||
if err := o.deleteOrEvictPodsSimple(info); err == nil {
|
||||
drainedNodes.Insert(info.Name)
|
||||
printObj(info.Object, o.Out)
|
||||
} else {
|
||||
@ -327,6 +323,12 @@ func (o *DrainCmdOptions) deleteOrEvictPodsSimple(nodeInfo *resource.Info) error
|
||||
if warnings := list.Warnings(); warnings != "" {
|
||||
fmt.Fprintf(o.ErrOut, "WARNING: %s\n", warnings)
|
||||
}
|
||||
if o.drainer.DryRun {
|
||||
for _, pod := range list.Pods() {
|
||||
fmt.Fprintf(o.Out, "evicting pod %s/%s (dry run)\n", pod.Namespace, pod.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := o.drainer.DeleteOrEvictPods(list.Pods()); err != nil {
|
||||
pendingList, newErrs := o.drainer.GetPodsForDeletion(nodeInfo.Name)
|
||||
|
@ -208,7 +208,7 @@ func (d *Helper) evictPods(pods []corev1.Pod, policyGroupVersion string, getPodF
|
||||
for _, pod := range pods {
|
||||
go func(pod corev1.Pod, returnCh chan error) {
|
||||
for {
|
||||
fmt.Fprintf(d.Out, "evicting pod %q\n", pod.Name)
|
||||
fmt.Fprintf(d.Out, "evicting pod %s/%s\n", pod.Namespace, pod.Name)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// return here or we'll leak a goroutine.
|
||||
|
Loading…
Reference in New Issue
Block a user