func (o *DrainCmdOptions) RunDrain() error {
	if err := o.RunCordonOrUncordon(true); err != nil {
		return err
	}

	printObj, err := o.ToPrinter("drained")
	if err != nil {
		return err
	}

	drainedNodes := sets.NewString()
	var fatal error

	for _, info := range o.nodeInfos {
		if err := o.deleteOrEvictPodsSimple(info); err == nil {
			drainedNodes.Insert(info.Name)
			printObj(info.Object, o.Out)
		} else {
			fmt.Fprintf(o.ErrOut, "error: unable to drain node %q, aborting command...\n\n", info.Name)
			remainingNodes := []string{}
			fatal = err
			for _, remainingInfo := range o.nodeInfos {
				if drainedNodes.Has(remainingInfo.Name) {
					continue
				}
				remainingNodes = append(remainingNodes, remainingInfo.Name)
			}

			if len(remainingNodes) > 0 {
				fmt.Fprintf(o.ErrOut, "There are pending nodes to be drained:\n")
				for _, nodeName := range remainingNodes {
					fmt.Fprintf(o.ErrOut, " %s\n", nodeName)
				}
			}
			break
		}
	}

	return fatal
}
// RunDrain runs the 'drain' command
RunDrain runs the 'drain' command
// RunDrain runs the ' drain ' command
func (o *DrainCmdOptions) RunDrain() error {
	if err := o.RunCordonOrUncordon(true); err != nil {
		return err
	}
	printObj, err := o.ToPrinter("drained")
	if err != nil {
		return err
	}
	drainedNodes := sets.NewString()
	var fatal error
	for _, info := range o.nodeInfos {
		if err := o.deleteOrEvictPodsSimple(info); err == nil {
			drainedNodes.Insert(info.Name)
			printObj(info.Object, o.Out)
		} else {
			fmt.Fprintf(o.ErrOut, "error: unable to drain node %q, aborting command...\n\n", info.Name)
			remainingNodes := []string{}
			fatal = err
			for _, remainingInfo := range o.nodeInfos {
				if drainedNodes.Has(remainingInfo.Name) {
					continue
				}
				remainingNodes = append(remainingNodes, remainingInfo.Name)
			}
			if len(remainingNodes) > 0 {
				fmt.Fprintf(o.ErrOut, "There are pending nodes to be drained:\n")
				for _, nodeName := range remainingNodes {
					fmt.Fprintf(o.ErrOut, " %s\n", nodeName)
				}
			}
			break
		}
	}
	return fatal
}
func ( o * DrainCmdOptions ) RunDrain ( ) error { if err := o . RunCordonOrUncordon ( true ) ; err != nil { return err } printObj , err := o . ToPrinter ( " " ) if err != nil { return err } drainedNodes := sets . NewString ( ) var fatal error for _ , info := range o . nodeInfos { if err := o . deleteOrEvictPodsSimple ( info ) ; err == nil { drainedNodes . Insert ( info . Name ) printObj ( info . Object , o . Out ) } else { fmt . Fprintf ( o . ErrOut , " \n \n " , info . Name ) remainingNodes := [ ] string { } fatal = err for _ , remainingInfo := range o . nodeInfos { if drainedNodes . Has ( remainingInfo . Name ) { continue } remainingNodes = append ( remainingNodes , remainingInfo . Name ) } if len ( remainingNodes ) > 0 { fmt . Fprintf ( o . ErrOut , " \n " ) for _ , nodeName := range remainingNodes { fmt . Fprintf ( o . ErrOut , " \n " , nodeName ) } } break } } return fatal }
RunDrain runs the 'drain' command
RunDrain runs the ' drain ' command