diff --git a/cmd/kk/pkg/etcd/module.go b/cmd/kk/pkg/etcd/module.go index 0de29475c..f454cba03 100644 --- a/cmd/kk/pkg/etcd/module.go +++ b/cmd/kk/pkg/etcd/module.go @@ -311,15 +311,6 @@ func handleExistCluster(c *ConfigureModule) []task.Interface { Parallel: false, } - restart := &task.RemoteTask{ - Name: "RestartETCD", - Desc: "Restart etcd", - Hosts: c.Runtime.GetHostsByRole(common.ETCD), - Prepare: &NodeETCDExist{Not: true}, - Action: new(RestartETCD), - Parallel: true, - } - newETCDNodeHealthCheck := &task.RemoteTask{ Name: "NewETCDNodeHealthCheck", Desc: "Health check on new etcd", @@ -360,7 +351,6 @@ func handleExistCluster(c *ConfigureModule) []task.Interface { existETCDHealthCheck, generateETCDConfig, joinMember, - restart, newETCDNodeHealthCheck, checkMember, allRefreshETCDConfig, diff --git a/cmd/kk/pkg/etcd/tasks.go b/cmd/kk/pkg/etcd/tasks.go index 400ca426e..052991e55 100644 --- a/cmd/kk/pkg/etcd/tasks.go +++ b/cmd/kk/pkg/etcd/tasks.go @@ -349,6 +349,12 @@ func (j *JoinMember) Execute(runtime connector.Runtime) error { } else { return errors.New("get etcd cluster status by pipeline cache failed") } + + // After adding a new member for etcd, it is necessary to start the new member as the etcd cluster may experience abnormal behavior. + if _, err := runtime.GetRunner().SudoCmd("systemctl daemon-reload && systemctl restart etcd && systemctl enable etcd", true); err != nil { + return errors.Wrap(errors.WithStack(err), "start etcd failed") + } + return nil }