From 332dab323266546c03dc6e69b83c72ae2c2d4f6b Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Wed, 10 Jan 2024 14:05:00 +0800 Subject: [PATCH 1/3] Remove more deprecated settings Signed-off-by: JaySon-Huang --- pkg/cluster/spec/tiflash.go | 51 +++++++++++++++++++++---------------- pkg/tidbver/tidbver.go | 5 ++++ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/pkg/cluster/spec/tiflash.go b/pkg/cluster/spec/tiflash.go index 0da37e424d..d2996cb2ff 100644 --- a/pkg/cluster/spec/tiflash.go +++ b/pkg/cluster/spec/tiflash.go @@ -459,8 +459,8 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, version string, pathConfig string isStorageDirsDefined bool deprecatedUsersConfig string - daemonConfig string - markCacheSize string + extraConfig string + clusterManagerConfig string err error ) if isStorageDirsDefined, err = checkTiFlashStorageConfigWithVersion(version, src); err != nil { @@ -527,44 +527,52 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, version string, return nil, err } - topo := Specification{} - if tidbver.TiFlashNotNeedSomeConfig(version) { - // For 5.4.0 or later, TiFlash can ignore application.runAsDaemon and mark_cache_size setting - daemonConfig = "#" - markCacheSize = "#" + // For 5.4.0 or later, TiFlash can ignore application.runAsDaemon, display_name, default_profile and mark_cache_size setting + extraConfig = "#" + } else { + extraConfig = fmt.Sprintf(` + application.runAsDaemon: true + display_name: "TiFlash" + default_profile: "default" + mark_cache_size: 5368709120 + tmp_path: "%s/tmp" + `, paths.Data[0]) + } + + // `cluster_manager` is removed since v6.0.0 + if tidbver.TiFlashNotNeedClusterManager(version) { + clusterManagerConfig = "#" } else { - daemonConfig = `application.runAsDaemon: true` - markCacheSize = `mark_cache_size: 5368709120` + clusterManagerConfig = fmt.Sprintf(` + flash.flash_cluster.cluster_manager_path: "%[2]s/bin/tiflash/flash_cluster_manager" + flash.flash_cluster.log: "%[1]s/tiflash_cluster_manager.log" + flash.flash_cluster.master_ttl: 60 + flash.flash_cluster.refresh_interval: 20 + flash.flash_cluster.update_rule_interval: 5 + `, paths.Log, paths.Deploy) } + topo := Specification{} err = yaml.Unmarshal([]byte(fmt.Sprintf(` server_configs: tiflash: - default_profile: "default" - display_name: "TiFlash" listen_host: "%[7]s" - tmp_path: "%[11]s" %[1]s %[3]s %[4]s flash.tidb_status_addr: "%[5]s" flash.service_addr: "%[6]s" - flash.flash_cluster.cluster_manager_path: "%[10]s/bin/tiflash/flash_cluster_manager" - flash.flash_cluster.log: "%[2]s/tiflash_cluster_manager.log" - flash.flash_cluster.master_ttl: 60 - flash.flash_cluster.refresh_interval: 20 - flash.flash_cluster.update_rule_interval: 5 flash.proxy.config: "%[10]s/conf/tiflash-learner.toml" status.metrics_port: %[8]d logger.errorlog: "%[2]s/tiflash_error.log" logger.log: "%[2]s/tiflash.log" logger.count: 20 logger.size: "1000M" - %[13]s raft.pd_addr: "%[9]s" + %[11]s %[12]s - %[14]s + %[13]s `, pathConfig, paths.Log, @@ -576,10 +584,9 @@ server_configs: spec.StatusPort, strings.Join(i.topo.(*Specification).GetPDList(), ","), paths.Deploy, - fmt.Sprintf("%s/tmp", paths.Data[0]), deprecatedUsersConfig, - daemonConfig, - markCacheSize, + extraConfig, + clusterManagerConfig, )), &topo) if err != nil { diff --git a/pkg/tidbver/tidbver.go b/pkg/tidbver/tidbver.go index eae857f78e..89858ebe82 100644 --- a/pkg/tidbver/tidbver.go +++ b/pkg/tidbver/tidbver.go @@ -88,6 +88,11 @@ func TiFlashNotNeedSomeConfig(version string) bool { return semver.Compare(version, "v5.4.0") >= 0 || strings.Contains(version, "nightly") } +// TiFlashNotNeedSomeConfig return if given version of TiFlash do not need to start `cluster_manager` +func TiFlashNotNeedClusterManager(version string) bool { + return semver.Compare(version, "v6.0.0") >= 0 || strings.Contains(version, "nightly") +} + // TiFlashPlaygroundNewStartMode return true if the given version of TiFlash could be started // with the new implementation in TiUP playground. func TiFlashPlaygroundNewStartMode(version string) bool { From e3e8d995c0dd586c4ab24e3ee89c46ebc9feb7b0 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Wed, 10 Jan 2024 14:16:39 +0800 Subject: [PATCH 2/3] Fix naming --- pkg/cluster/spec/tiflash.go | 6 +++--- pkg/tidbver/tidbver.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/cluster/spec/tiflash.go b/pkg/cluster/spec/tiflash.go index d2996cb2ff..f767ed1cb3 100644 --- a/pkg/cluster/spec/tiflash.go +++ b/pkg/cluster/spec/tiflash.go @@ -541,9 +541,7 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, version string, } // `cluster_manager` is removed since v6.0.0 - if tidbver.TiFlashNotNeedClusterManager(version) { - clusterManagerConfig = "#" - } else { + if tidbver.TiFlashNeedClusterManager(version) { clusterManagerConfig = fmt.Sprintf(` flash.flash_cluster.cluster_manager_path: "%[2]s/bin/tiflash/flash_cluster_manager" flash.flash_cluster.log: "%[1]s/tiflash_cluster_manager.log" @@ -551,6 +549,8 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, version string, flash.flash_cluster.refresh_interval: 20 flash.flash_cluster.update_rule_interval: 5 `, paths.Log, paths.Deploy) + } else { + clusterManagerConfig = "#" } topo := Specification{} diff --git a/pkg/tidbver/tidbver.go b/pkg/tidbver/tidbver.go index 89858ebe82..2f6e4d8f4a 100644 --- a/pkg/tidbver/tidbver.go +++ b/pkg/tidbver/tidbver.go @@ -88,9 +88,9 @@ func TiFlashNotNeedSomeConfig(version string) bool { return semver.Compare(version, "v5.4.0") >= 0 || strings.Contains(version, "nightly") } -// TiFlashNotNeedSomeConfig return if given version of TiFlash do not need to start `cluster_manager` -func TiFlashNotNeedClusterManager(version string) bool { - return semver.Compare(version, "v6.0.0") >= 0 || strings.Contains(version, "nightly") +// TiFlashNeedClusterManager return if given version of TiFlash do not need to start `cluster_manager` +func TiFlashNeedClusterManager(version string) bool { + return semver.Compare(version, "v6.0.0") < 0 && !strings.Contains(version, "nightly") } // TiFlashPlaygroundNewStartMode return true if the given version of TiFlash could be started From fbe2708f8b5549fb138f0a837c88a0413ec3f1fd Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Wed, 10 Jan 2024 14:38:24 +0800 Subject: [PATCH 3/3] Fix space in yaml template --- pkg/cluster/spec/tiflash.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/cluster/spec/tiflash.go b/pkg/cluster/spec/tiflash.go index f767ed1cb3..5fa3e927ae 100644 --- a/pkg/cluster/spec/tiflash.go +++ b/pkg/cluster/spec/tiflash.go @@ -532,12 +532,12 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, version string, extraConfig = "#" } else { extraConfig = fmt.Sprintf(` - application.runAsDaemon: true - display_name: "TiFlash" - default_profile: "default" - mark_cache_size: 5368709120 - tmp_path: "%s/tmp" - `, paths.Data[0]) + application.runAsDaemon: true + display_name: "TiFlash" + default_profile: "default" + mark_cache_size: 5368709120 + tmp_path: "%s/tmp" +`, paths.Data[0]) } // `cluster_manager` is removed since v6.0.0 @@ -548,7 +548,7 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, version string, flash.flash_cluster.master_ttl: 60 flash.flash_cluster.refresh_interval: 20 flash.flash_cluster.update_rule_interval: 5 - `, paths.Log, paths.Deploy) +`, paths.Log, paths.Deploy) } else { clusterManagerConfig = "#" } @@ -572,7 +572,7 @@ server_configs: raft.pd_addr: "%[9]s" %[11]s %[12]s - %[13]s + %[13]s `, pathConfig, paths.Log,