Commit bbf4d66b authored by Sharif Elgamal's avatar Sharif Elgamal

delete docker volumes when deleting a single node

parent 1eb346d3
......@@ -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})
},
}
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment