From b1353c5a6ac2eb8df33943c7ef80d650a95e92df Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Thu, 25 Mar 2021 13:47:52 +0000 Subject: [PATCH] add additional options to avoid node drain or delete getting stuck --- pkg/minikube/node/node.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/node/node.go b/pkg/minikube/node/node.go index 66cce3e99b79..0a12a845e4b9 100644 --- a/pkg/minikube/node/node.go +++ b/pkg/minikube/node/node.go @@ -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 { @@ -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)