From ec11a99ba1332b59678e86d6a9dd2cfb09cc64a8 Mon Sep 17 00:00:00 2001 From: Lonng Date: Thu, 23 Jul 2020 21:34:46 +0800 Subject: [PATCH] Support refresh configuration only when reload Signed-off-by: Lonng --- components/cluster/command/reload.go | 17 ++++++++++------- tests/tiup-cluster/script/scale_core.sh | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/components/cluster/command/reload.go b/components/cluster/command/reload.go index 3422d2d681..f231311576 100644 --- a/components/cluster/command/reload.go +++ b/components/cluster/command/reload.go @@ -29,6 +29,7 @@ import ( ) func newReloadCmd() *cobra.Command { + var skipRestart bool cmd := &cobra.Command{ Use: "reload ", Short: "Reload a TiDB cluster's config and restart if needed", @@ -59,7 +60,7 @@ func newReloadCmd() *cobra.Command { return err } - t, err := buildReloadTask(clusterName, metadata, gOpt) + t, err := buildReloadTask(clusterName, metadata, gOpt, skipRestart) if err != nil { return err } @@ -83,6 +84,7 @@ func newReloadCmd() *cobra.Command { cmd.Flags().StringSliceVarP(&gOpt.Nodes, "node", "N", nil, "Only start specified nodes") cmd.Flags().Int64Var(&gOpt.APITimeout, "transfer-timeout", 300, "Timeout in seconds when transferring PD and TiKV store leaders") cmd.Flags().BoolVarP(&gOpt.IgnoreConfigCheck, "ignore-config-check", "", false, "Ignore the config check result") + cmd.Flags().BoolVar(&skipRestart, "skip-restart", false, "Only refresh configuration to remote and do not restart services") return cmd } @@ -91,6 +93,7 @@ func buildReloadTask( clusterName string, metadata *spec.ClusterMeta, options operator.Options, + skipRestart bool, ) (task.Task, error) { var refreshConfigTasks []task.Task @@ -146,16 +149,16 @@ func buildReloadTask( } } - t := task.NewBuilder(). + tb := task.NewBuilder(). SSHKeySet( spec.ClusterPath(clusterName, "ssh", "id_rsa"), spec.ClusterPath(clusterName, "ssh", "id_rsa.pub")). ClusterSSH(metadata.Topology, metadata.User, gOpt.SSHTimeout). - Parallel(refreshConfigTasks...). - ClusterOperate(metadata.Topology, operator.UpgradeOperation, options). - Build() - - return t, nil + Parallel(refreshConfigTasks...) + if !skipRestart { + tb = tb.ClusterOperate(metadata.Topology, operator.UpgradeOperation, options) + } + return tb.Build(), nil } func validRoles(roles []string) error { diff --git a/tests/tiup-cluster/script/scale_core.sh b/tests/tiup-cluster/script/scale_core.sh index 55f976f66e..be4544cbd7 100755 --- a/tests/tiup-cluster/script/scale_core.sh +++ b/tests/tiup-cluster/script/scale_core.sh @@ -18,6 +18,8 @@ function scale_core() { tiup-cluster display $name + tiup-cluster reload $name --skip-restart + total_sub_one=18 echo "start scale in tidb"