Merge branch 'node-delete-vol' of github.com:sharifelgamal/minikube into restart

pull/7973/head
Sharif Elgamal 2020-05-20 15:00:58 -07:00
commit d5f9490ced
2 changed files with 13 additions and 6 deletions

View File

@ -18,6 +18,7 @@ package cmd
import (
"github.com/spf13/cobra"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/mustload"
"k8s.io/minikube/pkg/minikube/node"
@ -38,10 +39,16 @@ var nodeDeleteCmd = &cobra.Command{
co := mustload.Healthy(ClusterFlagValue())
out.T(out.DeletingHost, "Deleting node {{.name}} from cluster {{.cluster}}", out.V{"name": name, "cluster": co.Config.Name})
if err := node.Delete(*co.Config, name); err != nil {
n, err := node.Delete(*co.Config, name)
if err != nil {
exit.WithError("deleting node", err)
}
if driver.IsKIC(co.Config.Driver) {
machineName := driver.MachineName(*co.Config, *n)
deletePossibleKicLeftOver(machineName, co.Config.Driver)
}
out.T(out.Deleted, "Node {{.name}} was successfully deleted.", out.V{"name": name})
},
}

View File

@ -58,24 +58,24 @@ func Add(cc *config.ClusterConfig, n config.Node) error {
}
// Delete stops and deletes the given node from the given cluster
func Delete(cc config.ClusterConfig, name string) error {
func Delete(cc config.ClusterConfig, name string) (*config.Node, error) {
n, index, err := Retrieve(&cc, name)
if err != nil {
return errors.Wrap(err, "retrieve")
return n, errors.Wrap(err, "retrieve")
}
api, err := machine.NewAPIClient()
if err != nil {
return err
return n, err
}
err = machine.DeleteHost(api, driver.MachineName(cc, *n))
if err != nil {
return err
return n, err
}
cc.Nodes = append(cc.Nodes[:index], cc.Nodes[index+1:]...)
return config.SaveProfile(viper.GetString(config.ProfileName), &cc)
return n, config.SaveProfile(viper.GetString(config.ProfileName), &cc)
}
// Retrieve finds the node by name in the given cluster