Skip to content

Commit

Permalink
Fix the issue that prune command will regen config for removed nodes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklove authored Mar 24, 2021
1 parent 4d5347d commit 3fbcafb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/cluster/manager/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ func (m *Manager) DestroyTombstone(

b := m.sshTaskBuilder(name, topo, base.User, gOpt)

var nodes []string
b.
ctx := ctxt.New(context.Background())
nodes, err := operator.DestroyTombstone(ctx, cluster, true /* returnNodesOnly */, gOpt, tlsCfg)
if err != nil {
return err
}
regenConfigTasks, _ := buildRegenConfigTasks(m, name, topo, base, nodes, true)

t := b.
Func("FindTomestoneNodes", func(ctx context.Context) (err error) {
nodes, err = operator.DestroyTombstone(ctx, cluster, true /* returnNodesOnly */, gOpt, tlsCfg)

if !skipConfirm {
err = cliutil.PromptForConfirmOrAbortError(
color.HiYellowString(fmt.Sprintf("Will destroy these nodes: %v\nDo you confirm this action? [y/N]:", nodes)),
Expand All @@ -136,14 +142,12 @@ func (m *Manager) DestroyTombstone(
}).
ClusterOperate(cluster, operator.DestroyTombstoneOperation, gOpt, tlsCfg).
UpdateMeta(name, clusterMeta, nodes).
UpdateTopology(name, m.specManager.Path(name), clusterMeta, nodes)

regenConfigTasks, _ := buildRegenConfigTasks(m, name, topo, base, nodes, true)
t := b.
UpdateTopology(name, m.specManager.Path(name), clusterMeta, nodes).
ParallelStep("+ Refresh instance configs", true, regenConfigTasks...).
Parallel(true, buildReloadPromTasks(metadata.GetTopology())...).
Build()
if err := t.Execute(ctxt.New(context.Background())); err != nil {

if err := t.Execute(ctx); err != nil {
if errorx.Cast(err) != nil {
// FIXME: Map possible task errors and give suggestions.
return err
Expand Down

0 comments on commit 3fbcafb

Please sign in to comment.