From b21b24b913d4e223a94462259b569089880b9d5b Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Mon, 21 Jun 2021 12:30:52 +0800 Subject: [PATCH] cluster: increase default timeout transfer leader in upgrade progress (#1434) --- components/cluster/command/upgrade.go | 2 +- pkg/cluster/module/systemd.go | 5 +++++ pkg/cluster/operation/upgrade.go | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/components/cluster/command/upgrade.go b/components/cluster/command/upgrade.go index 76d76f76ac..a0c829be7f 100644 --- a/components/cluster/command/upgrade.go +++ b/components/cluster/command/upgrade.go @@ -42,7 +42,7 @@ func newUpgradeCmd() *cobra.Command { }, } cmd.Flags().BoolVar(&gOpt.Force, "force", false, "Force upgrade without transferring PD leader") - cmd.Flags().Uint64Var(&gOpt.APITimeout, "transfer-timeout", 300, "Timeout in seconds when transferring PD and TiKV store leaders") + cmd.Flags().Uint64Var(&gOpt.APITimeout, "transfer-timeout", 600, "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().BoolVarP(&offlineMode, "offline", "", false, "Upgrade a stopped cluster") diff --git a/pkg/cluster/module/systemd.go b/pkg/cluster/module/systemd.go index 513b36b3b9..37b6c393e0 100644 --- a/pkg/cluster/module/systemd.go +++ b/pkg/cluster/module/systemd.go @@ -36,6 +36,7 @@ type SystemdModuleConfig struct { ReloadDaemon bool // run daemon-reload before other actions Scope string // user, system or global Force bool // add the `--force` arg to systemctl command + Signal string // specify the signal to send to process Timeout time.Duration // timeout to execute the command } @@ -56,6 +57,10 @@ func NewSystemdModule(config SystemdModuleConfig) *SystemdModule { systemctl = fmt.Sprintf("%s --force", systemctl) } + if config.Signal != "" { + systemctl = fmt.Sprintf("%s --signal %s", systemctl, config.Signal) + } + switch config.Scope { case SystemdScopeUser: sudo = false // `--user` scope does not need root privilege diff --git a/pkg/cluster/operation/upgrade.go b/pkg/cluster/operation/upgrade.go index b11ee42406..1cd89bfc9f 100644 --- a/pkg/cluster/operation/upgrade.go +++ b/pkg/cluster/operation/upgrade.go @@ -55,6 +55,7 @@ func Upgrade( } log.Infof("Upgrading component %s", component.Name()) + // perform pre-upgrade actions of component var origLeaderScheduleLimit int var origRegionScheduleLimit int