Skip to content

Commit

Permalink
Move node config deletion out of drainNode and into Delete.
Browse files Browse the repository at this point in the history
Previously, drainNode would delete the node from the config, but this means the machine can no longer be properly cleaned up if the node is drained for non-deletion reasons (rejoining a cluster).
  • Loading branch information
andriyDev committed Jun 22, 2021
1 parent 31d9336 commit 1aae098
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/minikube/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func Add(cc *config.ClusterConfig, n config.Node, delOnFail bool) error {

// drainNode drains then deletes (removes) node from cluster.
func drainNode(cc config.ClusterConfig, name string) (*config.Node, error) {
n, index, err := Retrieve(cc, name)
n, _, err := Retrieve(cc, name)
if err != nil {
return n, errors.Wrap(err, "retrieve")
}
Expand Down Expand Up @@ -130,8 +130,7 @@ func drainNode(cc config.ClusterConfig, name string) (*config.Node, error) {
}
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)
return n, nil
}

// Delete calls drainNode to remove node from cluster and deletes the host.
Expand All @@ -152,7 +151,13 @@ func Delete(cc config.ClusterConfig, name string) (*config.Node, error) {
return n, err
}

return n, nil
_, index, err := Retrieve(cc, name)
if err != nil {
return n, errors.Wrap(err, "retrieve")
}

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

// Retrieve finds the node by name in the given cluster
Expand Down

0 comments on commit 1aae098

Please sign in to comment.