Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add additional options to avoid node drain or delete getting stuck #10926

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/minikube/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func drainNode(cc config.ClusterConfig, name string) (*config.Node, error) {
// ref: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#drain
kubectl := kapi.KubectlBinaryPath(cc.KubernetesConfig.KubernetesVersion)
cmd := exec.Command("sudo", "KUBECONFIG=/var/lib/minikube/kubeconfig", kubectl, "drain", m,
"--force", "--grace-period=1", "--disable-eviction", "--ignore-daemonsets", "--delete-emptydir-data")
"--force", "--grace-period=1", "--skip-wait-for-delete-timeout=1", "--disable-eviction", "--ignore-daemonsets", "--delete-emptydir-data", "--delete-local-data")
if _, err := runner.RunCmd(cmd); err != nil {
klog.Warningf("unable to drain node %q: %v", name, err)
} else {
Expand All @@ -121,10 +121,14 @@ func drainNode(cc config.ClusterConfig, name string) (*config.Node, error) {
return n, err
}

err = client.CoreV1().Nodes().Delete(context.Background(), m, v1.DeleteOptions{})
// set 'GracePeriodSeconds: 0' option to delete node immediately (ie, w/o waiting)
var grace *int64
err = client.CoreV1().Nodes().Delete(context.Background(), m, v1.DeleteOptions{GracePeriodSeconds: grace})
if err != nil {
klog.Errorf("unable to delete node %q: %v", name, err)
return n, err
}
klog.Infof("successfully deleted node %q", name)

cc.Nodes = append(cc.Nodes[:index], cc.Nodes[index+1:]...)
return n, config.SaveProfile(viper.GetString(config.ProfileName), &cc)
Expand Down