From 53e3af425c4c12ca33199a2f52f386db832ff5e6 Mon Sep 17 00:00:00 2001 From: SIGSEGV Date: Wed, 24 Mar 2021 18:23:37 +0800 Subject: [PATCH] Fix the issue that prune command will regen config for removed nodes (#1237) --- pkg/cluster/manager/destroy.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/cluster/manager/destroy.go b/pkg/cluster/manager/destroy.go index 179cff5cb5..8268ff130a 100644 --- a/pkg/cluster/manager/destroy.go +++ b/pkg/cluster/manager/destroy.go @@ -113,10 +113,15 @@ func (m *Manager) DestroyTombstone( b := m.sshTaskBuilder(name, topo, base.User, gOpt) - var nodes []string - b. + ctx := task.NewContext() + nodes, err := operator.DestroyTombstone(ctx, cluster, true /* returnNodesOnly */, gOpt, tlsCfg) + if err != nil { + return err + } + regenConfigTasks, _ := buildRegenConfigTasks(m, name, topo, base, nodes) + + t := b. Func("FindTomestoneNodes", func(ctx *task.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)), @@ -130,14 +135,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) - 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(task.NewContext()); err != nil { + + if err := t.Execute(ctx); err != nil { if errorx.Cast(err) != nil { // FIXME: Map possible task errors and give suggestions. return err