mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #105571 from yuzhiquan/remove-ignore-error-flag
Remove ignore error flag for drain, and set this feature as default
This commit is contained in:
commit
766a7e2e00
@ -192,7 +192,6 @@ func NewCmdDrain(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobr
|
||||
}
|
||||
cmd.Flags().BoolVar(&o.drainer.Force, "force", o.drainer.Force, "Continue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet.")
|
||||
cmd.Flags().BoolVar(&o.drainer.IgnoreAllDaemonSets, "ignore-daemonsets", o.drainer.IgnoreAllDaemonSets, "Ignore DaemonSet-managed pods.")
|
||||
cmd.Flags().BoolVar(&o.drainer.IgnoreErrors, "ignore-errors", o.drainer.IgnoreErrors, "Ignore errors occurred between drain nodes in group.")
|
||||
cmd.Flags().BoolVar(&o.drainer.DeleteEmptyDirData, "delete-local-data", o.drainer.DeleteEmptyDirData, "Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).")
|
||||
cmd.Flags().MarkDeprecated("delete-local-data", "This option is deprecated and will be deleted. Use --delete-emptydir-data.")
|
||||
cmd.Flags().BoolVar(&o.drainer.DeleteEmptyDirData, "delete-emptydir-data", o.drainer.DeleteEmptyDirData, "Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).")
|
||||
@ -298,8 +297,9 @@ func (o *DrainCmdOptions) RunDrain() error {
|
||||
}
|
||||
|
||||
drainedNodes := sets.NewString()
|
||||
var fatal error
|
||||
var fatal []error
|
||||
|
||||
remainingNodes := []string{}
|
||||
for _, info := range o.nodeInfos {
|
||||
if err := o.deleteOrEvictPodsSimple(info); err == nil {
|
||||
drainedNodes.Insert(info.Name)
|
||||
@ -311,34 +311,25 @@ func (o *DrainCmdOptions) RunDrain() error {
|
||||
|
||||
printObj(info.Object, o.Out)
|
||||
} else {
|
||||
if o.drainer.IgnoreErrors && len(o.nodeInfos) > 1 {
|
||||
fmt.Fprintf(o.ErrOut, "error: unable to drain node %q due to error:%s, continuing command...\n", info.Name, err)
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(o.ErrOut, "DEPRECATED WARNING: Aborting the drain command in a list of nodes will be deprecated in v1.23.\n"+
|
||||
"The new behavior will make the drain command go through all nodes even if one or more nodes failed during the drain.\n"+
|
||||
"For now, users can try such experience via: --ignore-errors\n")
|
||||
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)
|
||||
fmt.Fprintf(o.ErrOut, "error: unable to drain node %q due to error:%s, continuing command...\n", info.Name, err)
|
||||
|
||||
if !drainedNodes.Has(info.Name) {
|
||||
fatal = append(fatal, err)
|
||||
remainingNodes = append(remainingNodes, info.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
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return fatal
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
return utilerrors.NewAggregate(fatal)
|
||||
}
|
||||
|
||||
func (o *DrainCmdOptions) deleteOrEvictPodsSimple(nodeInfo *resource.Info) error {
|
||||
|
@ -59,7 +59,6 @@ type Helper struct {
|
||||
GracePeriodSeconds int
|
||||
|
||||
IgnoreAllDaemonSets bool
|
||||
IgnoreErrors bool
|
||||
Timeout time.Duration
|
||||
DeleteEmptyDirData bool
|
||||
Selector string
|
||||
|
Loading…
Reference in New Issue
Block a user