diff --git a/.github/workflows/integrate-cluster-cmd.yaml b/.github/workflows/integrate-cluster-cmd.yaml index f9c5839ba2..79b6416885 100644 --- a/.github/workflows/integrate-cluster-cmd.yaml +++ b/.github/workflows/integrate-cluster-cmd.yaml @@ -84,20 +84,24 @@ jobs: - name: Collect component log working-directory: ${{ env.working-directory }} - if: ${{ failure() }} # if: always() run: | docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-cluster/script/pull_log.sh /tiup-cluster/logs ls ${{ env.working-directory }} - tar czvf ${{ env.working-directory }}/logs.tar.gz ${{ env.working-directory }}/logs/ + + - name: Detect error log + working-directory: ${{ env.working-directory }} + # if: always() + run: | + bash ./tests/tiup-cluster/script/detect_error.sh ./logs/ - name: Upload component log if: ${{ failure() }} # if: always() - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: component_logs - path: ${{ env.working-directory }}/logs.tar.gz + path: ${{ env.working-directory }}/logs/ - name: Output cluster debug log working-directory: ${{ env.working-directory }} diff --git a/.github/workflows/integrate-cluster-scale.yaml b/.github/workflows/integrate-cluster-scale.yaml index 3b4c3b89ba..adbdca509a 100644 --- a/.github/workflows/integrate-cluster-scale.yaml +++ b/.github/workflows/integrate-cluster-scale.yaml @@ -84,20 +84,24 @@ jobs: - name: Collect component log working-directory: ${{ env.working-directory }} - if: ${{ failure() }} # if: always() run: | docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-cluster/script/pull_log.sh /tiup-cluster/logs ls ${{ env.working-directory }} - tar czvf ${{ env.working-directory }}/logs.tar.gz ${{ env.working-directory }}/logs/ + + - name: Detect error log + working-directory: ${{ env.working-directory }} + # if: always() + run: | + bash ./tests/tiup-cluster/script/detect_error.sh ./logs/ - name: Upload component log if: ${{ failure() }} # if: always() - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: cluster_logs - path: ${{ env.working-directory }}/logs.tar.gz + path: ${{ env.working-directory }}/logs/ - name: Output cluster debug log working-directory: ${{ env.working-directory }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 064c372154..f66306b23f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ TiUP Changelog +## [1.9.6] 2022-05-20 + +### Fix + +- Fix incorrect output of `display` in certain circumstances for `tiup-cluster` ([#1889](https://github.com/pingcap/tiup/pull/1889), [@srstack](https://github.com/srstack)) + ## [1.9.5] 2022-05-10 ### Fixes diff --git a/components/dm/command/deploy.go b/components/dm/command/deploy.go index 4e7a165c38..2343419b94 100644 --- a/components/dm/command/deploy.go +++ b/components/dm/command/deploy.go @@ -22,10 +22,10 @@ import ( operator "github.com/pingcap/tiup/pkg/cluster/operation" "github.com/pingcap/tiup/pkg/cluster/spec" "github.com/pingcap/tiup/pkg/cluster/task" + "github.com/pingcap/tiup/pkg/tidbver" "github.com/pingcap/tiup/pkg/tui" "github.com/pingcap/tiup/pkg/utils" "github.com/spf13/cobra" - "golang.org/x/mod/semver" ) func newDeployCmd() *cobra.Command { @@ -69,12 +69,7 @@ func newDeployCmd() *cobra.Command { } func supportVersion(vs string) error { - if !semver.IsValid(vs) { - return nil - } - - majorMinor := semver.MajorMinor(vs) - if semver.Compare(majorMinor, "v2.0") < 0 { + if !tidbver.DMSupportDeploy(vs) { return errors.Errorf("Only support version not less than v2.0") } diff --git a/components/dm/command/deploy_test.go b/components/dm/command/deploy_test.go index 82399c9fab..502bdd4621 100644 --- a/components/dm/command/deploy_test.go +++ b/components/dm/command/deploy_test.go @@ -10,12 +10,10 @@ func TestSupportVersion(t *testing.T) { assert := require.New(t) tests := map[string]bool{ // version to support or not - "v2.0.0": true, - "v3.0.0": true, - "v2.0.0-beta.1": true, - "v2.0.0-alpha": true, - "v1.0.1": false, - "v1.1.1": false, + "v2.0.0": true, + "v6.0.0": true, + "v1.0.1": false, + "v1.1.1": false, } for v, support := range tests { diff --git a/components/playground/instance/ticdc.go b/components/playground/instance/ticdc.go index 562d42d504..da2d683913 100644 --- a/components/playground/instance/ticdc.go +++ b/components/playground/instance/ticdc.go @@ -20,8 +20,8 @@ import ( "strings" tiupexec "github.com/pingcap/tiup/pkg/exec" + "github.com/pingcap/tiup/pkg/tidbver" "github.com/pingcap/tiup/pkg/utils" - "golang.org/x/mod/semver" ) // TiCDC represent a ticdc instance. @@ -62,9 +62,8 @@ func (c *TiCDC) Start(ctx context.Context, version utils.Version) error { fmt.Sprintf("--log-file=%s", c.LogFile()), } clusterVersion := string(version) - if semver.Compare(clusterVersion, "v4.0.13") >= 0 { - if (semver.Major(clusterVersion) == "v4" && semver.Compare(clusterVersion, "v4.0.14") >= 0) || - (semver.Major(clusterVersion) == "v5" && semver.Compare(clusterVersion, "v5.0.3") >= 0) { + if tidbver.TiCDCSupportConfigFile(clusterVersion) { + if tidbver.TiCDCSupportDataDir(clusterVersion) { args = append(args, fmt.Sprintf("--data-dir=%s", filepath.Join(c.Dir, "data"))) } else { args = append(args, fmt.Sprintf("--sort-dir=%s/tmp/sorter", filepath.Join(c.Dir, "data"))) diff --git a/components/playground/instance/tiflash_config.go b/components/playground/instance/tiflash_config.go index 02a4b92ec4..ddf825c5ef 100644 --- a/components/playground/instance/tiflash_config.go +++ b/components/playground/instance/tiflash_config.go @@ -18,8 +18,8 @@ import ( "io" "strings" + "github.com/pingcap/tiup/pkg/tidbver" "github.com/pingcap/tiup/pkg/utils" - "golang.org/x/mod/semver" ) const tiflashDaemonConfig = ` @@ -104,7 +104,7 @@ func writeTiFlashConfig(w io.Writer, version utils.Version, tcpPort, httpPort, s logDir := fmt.Sprintf("%s/log", deployDir) ip := AdvertiseHost(host) var conf string - if semver.Compare(version.String(), "v5.4.0") >= 0 || version.IsNightly() { + if tidbver.TiFlashNotNeedSomeConfig(version.String()) { conf = fmt.Sprintf(tiflashConfig, pdAddrs, httpPort, tcpPort, deployDir, dataDir, tmpDir, logDir, servicePort, metricsPort, ip, strings.Join(tidbStatusAddrs, ","), clusterManagerPath, "") diff --git a/components/playground/instance/tiflash_proxy_config.go b/components/playground/instance/tiflash_proxy_config.go index 29bef476ad..868974711e 100644 --- a/components/playground/instance/tiflash_proxy_config.go +++ b/components/playground/instance/tiflash_proxy_config.go @@ -17,8 +17,8 @@ import ( "fmt" "io" + "github.com/pingcap/tiup/pkg/tidbver" "github.com/pingcap/tiup/pkg/utils" - "golang.org/x/mod/semver" ) const tiflashProxyConfig = ` @@ -52,7 +52,7 @@ func writeTiFlashProxyConfig(w io.Writer, version utils.Version, host, deployDir logDir := fmt.Sprintf("%s/log", deployDir) ip := AdvertiseHost(host) var statusAddr string - if semver.Compare(version.String(), "v4.0.5") >= 0 || version.IsNightly() { + if tidbver.TiFlashSupportAdvertiseStatusAddr(version.String()) { statusAddr = fmt.Sprintf(`status-addr = "0.0.0.0:%[2]d" advertise-status-addr = "%[1]s:%[2]d"`, ip, proxyStatusPort) } else { diff --git a/embed/examples/dm/minimal.yaml b/embed/examples/dm/minimal.yaml index c93a5e3202..ab8300b10e 100644 --- a/embed/examples/dm/minimal.yaml +++ b/embed/examples/dm/minimal.yaml @@ -26,9 +26,6 @@ monitoring_servers: grafana_servers: - host: 172.19.0.101 - # config: # Enable this part if you want to use WebUI, make sure tiup dm -v newer than v1.9.0. - # auth.anonymous.enabled: true - # security.allow_embedding: true alertmanager_servers: - host: 172.19.0.101 diff --git a/embed/examples/dm/topology.example.yaml b/embed/examples/dm/topology.example.yaml index 0ed7bbf4e3..b6faa986a5 100644 --- a/embed/examples/dm/topology.example.yaml +++ b/embed/examples/dm/topology.example.yaml @@ -68,9 +68,6 @@ grafana_servers: # deploy_dir: /tidb-deploy/grafana-3000 # grafana dashboard dir on TiUP machine # dashboard_dir: /home/tidb/dashboards - # config: # Enable this part if you want to use WebUI, make sure tiup dm -v newer than v1.9.0. - # auth.anonymous.enabled: true - # security.allow_embedding: true alertmanager_servers: - host: 10.0.1.15 diff --git a/pkg/cluster/manager/basic.go b/pkg/cluster/manager/basic.go index 0096d775df..8647d3a8da 100644 --- a/pkg/cluster/manager/basic.go +++ b/pkg/cluster/manager/basic.go @@ -31,9 +31,9 @@ import ( "github.com/pingcap/tiup/pkg/cluster/task" "github.com/pingcap/tiup/pkg/meta" "github.com/pingcap/tiup/pkg/set" + "github.com/pingcap/tiup/pkg/tidbver" "github.com/pingcap/tiup/pkg/tui" "github.com/pingcap/tiup/pkg/utils" - "golang.org/x/mod/semver" ) // EnableCluster enable/disable the service in a cluster @@ -296,7 +296,7 @@ func getMonitorHosts(topo spec.Topology) (map[string]hostInfo, set.StringSet) { func checkTiFlashWithTLS(topo spec.Topology, version string) error { if clusterSpec, ok := topo.(*spec.Specification); ok { if clusterSpec.GlobalOptions.TLSEnabled { - if (semver.Compare(version, "v4.0.5") < 0 && + if (!tidbver.TiFlashSupportTLS(version) && len(clusterSpec.TiFlashServers) > 0) && version != utils.NightlyVersionAlias { return fmt.Errorf("TiFlash %s is not supported in TLS enabled cluster", version) diff --git a/pkg/cluster/manager/display.go b/pkg/cluster/manager/display.go index e8b72d3b48..0d29b95022 100644 --- a/pkg/cluster/manager/display.go +++ b/pkg/cluster/manager/display.go @@ -24,6 +24,7 @@ import ( "sort" "strconv" "strings" + "sync" "time" "github.com/fatih/color" @@ -362,12 +363,16 @@ func (m *Manager) DisplayTiKVLabels(name string, opt operator.Options) error { if err != nil { return err } + + var mu sync.Mutex topo.IterInstance(func(ins spec.Instance) { if ins.ComponentName() == spec.ComponentPD { status := ins.Status(ctx, statusTimeout, tlsCfg, masterList...) if strings.HasPrefix(status, "Up") || strings.HasPrefix(status, "Healthy") { instAddr := fmt.Sprintf("%s:%d", ins.GetHost(), ins.GetPort()) + mu.Lock() masterActive = append(masterActive, instAddr) + mu.Unlock() } } }, opt.Concurrency) @@ -482,6 +487,7 @@ func (m *Manager) GetClusterTopology(name string, opt operator.Options) ([]InstI masterActive := make([]string, 0) masterStatus := make(map[string]string) + var mu sync.Mutex topo.IterInstance(func(ins spec.Instance) { if ins.ComponentName() != spec.ComponentPD && ins.ComponentName() != spec.ComponentDMMaster { return @@ -490,7 +496,9 @@ func (m *Manager) GetClusterTopology(name string, opt operator.Options) ([]InstI status := ins.Status(ctx, statusTimeout, tlsCfg, masterList...) if strings.HasPrefix(status, "Up") || strings.HasPrefix(status, "Healthy") { instAddr := fmt.Sprintf("%s:%d", ins.GetHost(), ins.GetPort()) + mu.Lock() masterActive = append(masterActive, instAddr) + mu.Unlock() } masterStatus[ins.ID()] = status }, opt.Concurrency) @@ -564,6 +572,7 @@ func (m *Manager) GetClusterTopology(name string, opt operator.Options) ([]InstI if ins.IsPatched() { roleName += " (patched)" } + mu.Lock() clusterInstInfos = append(clusterInstInfos, InstInfo{ ID: ins.ID(), Role: roleName, @@ -577,6 +586,7 @@ func (m *Manager) GetClusterTopology(name string, opt operator.Options) ([]InstI Port: ins.GetPort(), Since: since, }) + mu.Unlock() }, opt.Concurrency) // Sort by role,host,ports diff --git a/pkg/cluster/spec/cdc.go b/pkg/cluster/spec/cdc.go index a4a52fd70d..82d5f79552 100644 --- a/pkg/cluster/spec/cdc.go +++ b/pkg/cluster/spec/cdc.go @@ -24,7 +24,7 @@ import ( "github.com/pingcap/tiup/pkg/cluster/ctxt" "github.com/pingcap/tiup/pkg/cluster/template/scripts" "github.com/pingcap/tiup/pkg/meta" - "golang.org/x/mod/semver" + "github.com/pingcap/tiup/pkg/tidbver" ) // CDCSpec represents the Drainer topology specification in topology.yaml @@ -163,7 +163,7 @@ func (i *CDCInstance) InitConfig( globalConfig := topo.ServerConfigs.CDC instanceConfig := spec.Config - if semver.Compare(clusterVersion, "v4.0.13") == -1 { + if !tidbver.TiCDCSupportConfigFile(clusterVersion) { if len(globalConfig)+len(instanceConfig) > 0 { return perrs.New("server_config is only supported with TiCDC version v4.0.13 or later") } diff --git a/pkg/cluster/spec/profile.go b/pkg/cluster/spec/profile.go index cf852cb2e7..7ad4ba7c5d 100644 --- a/pkg/cluster/spec/profile.go +++ b/pkg/cluster/spec/profile.go @@ -59,14 +59,19 @@ var initialized = false // The directory will be created before return if it does not already exist. func Initialize(base string) error { tiupData := os.Getenv(tiuplocaldata.EnvNameComponentDataDir) - if tiupData == "" { + tiupHome := os.Getenv(tiuplocaldata.EnvNameHome) + + switch { + case tiupData != "": + profileDir = tiupData + case tiupHome != "": + profileDir = path.Join(tiupHome, tiuplocaldata.StorageParentDir, base) + default: homeDir, err := getHomeDir() if err != nil { return errors.Trace(err) } profileDir = path.Join(homeDir, ".tiup", tiuplocaldata.StorageParentDir, base) - } else { - profileDir = tiupData } clusterBaseDir := filepath.Join(profileDir, TiUPClusterDir) diff --git a/pkg/cluster/spec/spec.go b/pkg/cluster/spec/spec.go index e13ddcd024..19c62cf0f5 100644 --- a/pkg/cluster/spec/spec.go +++ b/pkg/cluster/spec/spec.go @@ -31,11 +31,10 @@ import ( "github.com/pingcap/tiup/pkg/cluster/template/scripts" "github.com/pingcap/tiup/pkg/meta" "github.com/pingcap/tiup/pkg/proxy" + "github.com/pingcap/tiup/pkg/tidbver" "github.com/pingcap/tiup/pkg/tui" - "github.com/pingcap/tiup/pkg/utils" clientv3 "go.etcd.io/etcd/client/v3" "go.uber.org/zap" - "golang.org/x/mod/semver" ) const ( @@ -413,12 +412,12 @@ func (s *Specification) GetPDList() []string { // AdjustByVersion modify the spec by cluster version. func (s *Specification) AdjustByVersion(clusterVersion string) { // CDC does not support data dir for version below v4.0.13, and also v5.0.0-rc, set it to empty. - if semver.Compare(clusterVersion, "v4.0.13") == -1 || clusterVersion == "v5.0.0-rc" { + if !tidbver.TiCDCSupportConfigFile(clusterVersion) { for _, server := range s.CDCServers { server.DataDir = "" } } - if semver.Compare(clusterVersion, "v5.4.0") >= 0 || strings.Contains(clusterVersion, utils.NightlyVersionAlias) { + if tidbver.NgMonitorDeployByDefault(clusterVersion) { for _, m := range s.Monitors { if m.NgPort == 0 { m.NgPort = 12020 diff --git a/pkg/cluster/spec/spec_test.go b/pkg/cluster/spec/spec_test.go index b9fa52ef55..2c63e49426 100644 --- a/pkg/cluster/spec/spec_test.go +++ b/pkg/cluster/spec/spec_test.go @@ -740,8 +740,6 @@ cdc_servers: "v5.1.0": {true, true, true}, "v5.0.0-rc": {false, false, false}, - "v5.1.0-alpha": {true, true, false}, - "v5.2.0-alpha": {true, true, false}, "v6.0.0-alpha": {true, true, true}, "v6.1.0": {true, true, true}, "v99.0.0": {true, true, true}, diff --git a/pkg/cluster/spec/tidb.go b/pkg/cluster/spec/tidb.go index 6a9bd0cd48..469dc22104 100644 --- a/pkg/cluster/spec/tidb.go +++ b/pkg/cluster/spec/tidb.go @@ -24,7 +24,7 @@ import ( "github.com/pingcap/tiup/pkg/cluster/ctxt" "github.com/pingcap/tiup/pkg/cluster/template/scripts" "github.com/pingcap/tiup/pkg/meta" - "golang.org/x/mod/semver" + "github.com/pingcap/tiup/pkg/tidbver" ) // TiDBSpec represents the TiDB topology specification in topology.yaml @@ -146,7 +146,7 @@ func (i *TiDBInstance) InitConfig( AppendEndpoints(topo.Endpoints(deployUser)...). WithListenHost(i.GetListenHost()). WithAdvertiseAddr(spec.Host). - SupportSecureBootstrap(semver.Compare(clusterVersion, "v5.3.0") >= 0) + SupportSecureBootstrap(tidbver.TiDBSupportSecureBoot(clusterVersion)) fp := filepath.Join(paths.Cache, fmt.Sprintf("run_tidb_%s_%d.sh", i.GetHost(), i.GetPort())) if err := cfg.ConfigToFile(fp); err != nil { return err diff --git a/pkg/cluster/spec/tiflash.go b/pkg/cluster/spec/tiflash.go index 2e1f954a1c..771edb8f23 100644 --- a/pkg/cluster/spec/tiflash.go +++ b/pkg/cluster/spec/tiflash.go @@ -34,8 +34,8 @@ import ( "github.com/pingcap/tiup/pkg/cluster/template/scripts" "github.com/pingcap/tiup/pkg/meta" "github.com/pingcap/tiup/pkg/set" + "github.com/pingcap/tiup/pkg/tidbver" "github.com/pingcap/tiup/pkg/utils" - "golang.org/x/mod/semver" "gopkg.in/yaml.v2" ) @@ -363,7 +363,7 @@ func (i *TiFlashInstance) CheckIncorrectConfigs() error { // need to check the configuration after clusterVersion >= v4.0.9. func checkTiFlashStorageConfigWithVersion(clusterVersion string, config map[string]interface{}) (bool, error) { - if semver.Compare(clusterVersion, "v4.0.9") >= 0 || utils.Version(clusterVersion).IsNightly() { + if tidbver.TiFlashSupportMultiDisksDeployment(clusterVersion) { return checkTiFlashStorageConfig(config) } return false, nil @@ -388,7 +388,7 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, cfg *scripts.Ti pathConfig = fmt.Sprintf(`path: "%s"`, cfg.DataDir) } - if (semver.Compare(clusterVersion, "v4.0.12") >= 0 && semver.Compare(clusterVersion, "v5.0.0-rc") != 0) || utils.Version(clusterVersion).IsNightly() { + if tidbver.TiFlashDeprecatedUsersConfig(clusterVersion) { // For v4.0.12 or later, 5.0.0 or later, TiFlash can ignore these `user.*`, `quotas.*` settings deprecatedUsersConfig = "#" } else { @@ -429,7 +429,7 @@ func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, cfg *scripts.Ti topo := Specification{} - if semver.Compare(clusterVersion, "v5.4.0") >= 0 || utils.Version(clusterVersion).IsNightly() { + if tidbver.TiFlashNotNeedSomeConfig(clusterVersion) { // For 5.4.0 or later, TiFlash can ignore application.runAsDaemon setting daemonConfig = "#" } else { @@ -499,7 +499,7 @@ func (i *TiFlashInstance) InitTiFlashLearnerConfig(ctx context.Context, cfg *scr firstDataDir := strings.Split(cfg.DataDir, ",")[0] - if semver.Compare(clusterVersion, "v4.0.5") >= 0 || utils.Version(clusterVersion).IsNightly() { + if tidbver.TiFlashSupportAdvertiseStatusAddr(clusterVersion) { statusAddr = fmt.Sprintf(`server.status-addr: "0.0.0.0:%[2]d" server.advertise-status-addr: "%[1]s:%[2]d"`, cfg.IP, cfg.FlashProxyStatusPort) } else { diff --git a/pkg/cluster/template/config/prometheus.go b/pkg/cluster/template/config/prometheus.go index b21cb2846f..69ef056d2b 100644 --- a/pkg/cluster/template/config/prometheus.go +++ b/pkg/cluster/template/config/prometheus.go @@ -21,7 +21,7 @@ import ( "text/template" "github.com/pingcap/tiup/embed" - "golang.org/x/mod/semver" + "github.com/pingcap/tiup/pkg/tidbver" ) // PrometheusConfig represent the data to generate Prometheus config @@ -57,14 +57,11 @@ type PrometheusConfig struct { // NewPrometheusConfig returns a PrometheusConfig func NewPrometheusConfig(clusterName, clusterVersion string, enableTLS bool) *PrometheusConfig { cfg := &PrometheusConfig{ - ClusterName: clusterName, - TLSEnabled: enableTLS, + ClusterName: clusterName, + TLSEnabled: enableTLS, + HasTiKVAccelerateRules: tidbver.PrometheusHasTiKVAccelerateRules(clusterVersion), } - // tikv.accelerate.rules.yml was first introduced in v4.0.0 - if semver.Compare(clusterVersion, "v4.0.0") >= 0 { - cfg.HasTiKVAccelerateRules = true - } return cfg } diff --git a/pkg/cluster/template/scripts/cdc.go b/pkg/cluster/template/scripts/cdc.go index 4b4b6298f4..9775323544 100644 --- a/pkg/cluster/template/scripts/cdc.go +++ b/pkg/cluster/template/scripts/cdc.go @@ -20,7 +20,7 @@ import ( "text/template" "github.com/pingcap/tiup/embed" - "golang.org/x/mod/semver" + "github.com/pingcap/tiup/pkg/tidbver" ) // CDCScript represent the data to generate cdc config @@ -126,25 +126,14 @@ func (c *CDCScript) AppendEndpoints(ends ...*PDScript) *CDCScript { func (c *CDCScript) PatchByVersion(clusterVersion, dataDir string) *CDCScript { // config support since v4.0.13, ignore v5.0.0-rc // the same to data-dir, but we treat it as --sort-dir - if semver.Compare(clusterVersion, "v4.0.13") >= 0 && clusterVersion != "v5.0.0-rc" { + if tidbver.TiCDCSupportConfigFile(clusterVersion) { c = c.WithConfigFileEnabled().WithDataDir(dataDir) } // cdc support --data-dir since v4.0.14 and v5.0.3 - if semver.Major(clusterVersion) == "v4" && semver.Compare(clusterVersion, "v4.0.14") >= 0 { + if tidbver.TiCDCSupportDataDir(clusterVersion) { c = c.WithDataDirEnabled() } - // for those version above v5.0.3, cdc does not support --data-dir - ignoreVersion := map[string]struct{}{ - "v5.1.0-alpha": {}, - "v5.2.0-alpha": {}, - } - if semver.Compare(clusterVersion, "v5.0.3") >= 0 { - if _, ok := ignoreVersion[clusterVersion]; !ok { - c = c.WithDataDirEnabled() - } - } - return c } diff --git a/pkg/cluster/template/scripts/tikv.go b/pkg/cluster/template/scripts/tikv.go index 33222da0e2..d5ba933f83 100644 --- a/pkg/cluster/template/scripts/tikv.go +++ b/pkg/cluster/template/scripts/tikv.go @@ -21,11 +21,7 @@ import ( "text/template" "github.com/pingcap/tiup/embed" - "golang.org/x/mod/semver" -) - -const ( - advertiseStatusAddrSupportedFrom = "v4.0.1" + "github.com/pingcap/tiup/pkg/tidbver" ) // TiKVScript represent the data to generate TiKV config @@ -55,7 +51,7 @@ func NewTiKVScript(version, ip string, port, statusPort int, deployDir, dataDir, DeployDir: deployDir, DataDir: dataDir, LogDir: logDir, - SupportAdvertiseStatusAddr: semver.Compare(version, advertiseStatusAddrSupportedFrom) >= 0, + SupportAdvertiseStatusAddr: tidbver.TiKVSupportAdvertiseStatusAddr(version), } } diff --git a/pkg/tidbver/tidbver.go b/pkg/tidbver/tidbver.go new file mode 100644 index 0000000000..8f3b53d1a2 --- /dev/null +++ b/pkg/tidbver/tidbver.go @@ -0,0 +1,94 @@ +// Copyright 2022 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +package tidbver + +import ( + "strings" + + "golang.org/x/mod/semver" +) + +// warning: invalid semantic version string is considered less than a valid one when using semver.Compare + +// TiDBSupportSecureBoot return if given version of TiDB support secure boot +func TiDBSupportSecureBoot(version string) bool { + return semver.Compare(version, "v5.3.0") >= 0 || strings.Contains(version, "nightly") +} + +// TiKVSupportAdvertiseStatusAddr return if given version of TiKV support --advertise-status-addr +func TiKVSupportAdvertiseStatusAddr(version string) bool { + // TiKV support --advertise-status-addr since v4.0.1 + return semver.Compare(version, "v4.0.1") >= 0 || strings.Contains(version, "nightly") +} + +// TiFlashSupportTLS return if given version of TiFlash support TLS +func TiFlashSupportTLS(version string) bool { + return semver.Compare(version, "v4.0.5") >= 0 || strings.Contains(version, "nightly") +} + +// TiFlashSupportAdvertiseStatusAddr return if given version of TiFlash support --advertise-status-addr +func TiFlashSupportAdvertiseStatusAddr(version string) bool { + // TiFlash support --advertise-status-addr since v4.0.5 + return semver.Compare(version, "v4.0.5") >= 0 || strings.Contains(version, "nightly") +} + +// TiFlashSupportMultiDisksDeployment return if given version of TiFlash support multi-disks deployment +func TiFlashSupportMultiDisksDeployment(version string) bool { + // https://github.com/pingcap/tiup/pull/931 + return semver.Compare(version, "v4.0.9") >= 0 || strings.Contains(version, "nightly") +} + +// TiFlashDeprecatedUsersConfig return if given version of TiFlash deprecated users.* config +func TiFlashDeprecatedUsersConfig(version string) bool { + // https://github.com/pingcap/tiup/pull/1211 + return semver.Compare(version, "v4.0.12") >= 0 && version != "v5.0.0-rc" || strings.Contains(version, "nightly") +} + +// TiFlashNotNeedSomeConfig return if given version of TiFlash do not need some config like runAsDaemon +func TiFlashNotNeedSomeConfig(version string) bool { + // https://github.com/pingcap/tiup/pull/1673 + return semver.Compare(version, "v5.4.0") >= 0 || strings.Contains(version, "nightly") +} + +// TiCDCSupportConfigFile return if given version of TiCDC support config file +func TiCDCSupportConfigFile(version string) bool { + // config support since v4.0.13, ignore v5.0.0-rc + return semver.Compare(version, "v4.0.13") >= 0 && version != "v5.0.0-rc" || strings.Contains(version, "nightly") +} + +// TiCDCSupportDataDir return if given version of TiCDC support --data-dir +func TiCDCSupportDataDir(version string) bool { + // TiCDC support --data-dir since v4.0.14 and v5.0.3 + if semver.Compare(version, "v5.0.3") >= 0 || strings.Contains(version, "nightly") { + return true + } + return semver.Major(version) == "v4" && semver.Compare(version, "v4.0.14") >= 0 +} + +// NgMonitorDeployByDefault return if given version of TiDB cluster should contain ng-monitoring +func NgMonitorDeployByDefault(version string) bool { + return semver.Compare(version, "v5.4.0") >= 0 || strings.Contains(version, "nightly") +} + +// PrometheusHasTiKVAccelerateRules return if given version of Prometheus has TiKV accelerateRules +func PrometheusHasTiKVAccelerateRules(version string) bool { + // tikv.accelerate.rules.yml was first introduced in v4.0.0 + return semver.Compare(version, "v4.0.0") >= 0 || strings.Contains(version, "nightly") +} + +// DMSupportDeploy return if given version of DM is supported bu tiup-dm +func DMSupportDeploy(version string) bool { + // tiup-dm only support version not less than v2.0 + return semver.Compare(version, "v2.0.0") >= 0 || strings.Contains(version, "nightly") +} diff --git a/pkg/version/version.go b/pkg/version/version.go index be1219c9fe..fddd3dbd4f 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -23,7 +23,7 @@ var ( // TiUPVerMinor is the minor version of TiUP TiUPVerMinor = 9 // TiUPVerPatch is the patch version of TiUP - TiUPVerPatch = 5 + TiUPVerPatch = 6 // TiUPVerName is an alternative name of the version TiUPVerName = "tiup" // GitHash is the current git commit hash diff --git a/tests/tiup-cluster/script/detect_error.sh b/tests/tiup-cluster/script/detect_error.sh new file mode 100755 index 0000000000..b22c02397c --- /dev/null +++ b/tests/tiup-cluster/script/detect_error.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -eu + +err_num=$(find $1 -name "*.log" -exec grep "\[ERROR\]" {} \; | wc -l) +if [ ${err_num} != "0" ]; then + echo "detect ${err_num} [ERROR] log" + exit 1 +fi + +err_num=$(find $1 -name "*stderr.log" -exec cat {} \; | wc -l) +if [ ${err_num} != "0" ]; then + echo "detect ${err_num} stderr log" + exit 1 +fi + +echo "no error log found" diff --git a/tests/tiup-cluster/test_cmd_tls_native_ssh.sh b/tests/tiup-cluster/test_cmd_tls_native_ssh.sh index b6b42b39a4..e6ee83c2b0 100755 --- a/tests/tiup-cluster/test_cmd_tls_native_ssh.sh +++ b/tests/tiup-cluster/test_cmd_tls_native_ssh.sh @@ -6,6 +6,6 @@ source script/cmd_subtest.sh export GO_FAILPOINTS='github.com/pingcap/tiup/pkg/cluster/executor/assertNativeSSH=return(true)' echo "test cluster for version v4.0.12 w/ TLS, via native ssh" -cmd_subtest 4.0.12 true true +cmd_subtest 6.0.0 true true unset GO_FAILPOINTS diff --git a/tests/tiup-cluster/test_scale_core.sh b/tests/tiup-cluster/test_scale_core.sh index ecaeed92fa..d1e6fcdd65 100755 --- a/tests/tiup-cluster/test_scale_core.sh +++ b/tests/tiup-cluster/test_scale_core.sh @@ -5,4 +5,4 @@ set -eu source script/scale_core.sh echo "test scaling of core components in cluster for version v4.0.12 wo/ TLS, via easy ssh" -scale_core v4.0.12 false false +scale_core v6.0.0 false false diff --git a/tests/tiup-cluster/test_scale_core_tls.sh b/tests/tiup-cluster/test_scale_core_tls.sh index 5c09b082c8..0b9efabda2 100755 --- a/tests/tiup-cluster/test_scale_core_tls.sh +++ b/tests/tiup-cluster/test_scale_core_tls.sh @@ -5,4 +5,4 @@ set -eu source script/scale_core.sh echo "test scaling of core components in cluster for version v5.3.0 w/ TLS, via easy ssh" -scale_core v5.3.0 true false +scale_core v4.0.12 true false diff --git a/tests/tiup-cluster/test_scale_tools_tls.sh b/tests/tiup-cluster/test_scale_tools_tls.sh index b3b9aaddb6..f0060b60f9 100755 --- a/tests/tiup-cluster/test_scale_tools_tls.sh +++ b/tests/tiup-cluster/test_scale_tools_tls.sh @@ -5,4 +5,4 @@ set -eu source script/scale_tools.sh echo "test scaling of tools components in cluster for version v5.3.0 w/ TLS, via easy ssh" -scale_tools v5.3.0 true false +scale_tools v6.0.0 true false diff --git a/tests/tiup-cluster/test_upgrade_tls.sh b/tests/tiup-cluster/test_upgrade_tls.sh index 54f93198dd..de51d7bd6d 100755 --- a/tests/tiup-cluster/test_upgrade_tls.sh +++ b/tests/tiup-cluster/test_upgrade_tls.sh @@ -3,7 +3,7 @@ set -eu old_version=${old_version-v4.0.15} -version=${version-v5.3.0} +version=${version-v6.0.0} source script/upgrade.sh diff --git a/tests/tiup-playground/test_playground.sh b/tests/tiup-playground/test_playground.sh index 9eb8d0d7b4..58f5a3ba3c 100755 --- a/tests/tiup-playground/test_playground.sh +++ b/tests/tiup-playground/test_playground.sh @@ -47,11 +47,12 @@ function kill_all() { killall -9 grafana-server || true killall -9 tiup-playground || true killall -9 prometheus || true + killall -9 ng-monitoring-server || true cat $outfile } outfile=/tmp/tiup-playground-test.out -tiup-playground v5.0.1 > $outfile 2>&1 & +tiup-playground v6.0.0 > $outfile 2>&1 & # wait $outfile generated sleep 3 @@ -98,10 +99,10 @@ tiup-playground display | grep -E "terminated|exit" | wc -l | grep -q "1" killall -2 tiup-playground.test || killall -2 tiup-playground -sleep 60 +sleep 100 # test restart with same data -tiup-playground v5.0.1 > $outfile 2>&1 & +tiup-playground v6.0.0 > $outfile 2>&1 & # wait $outfile generated sleep 3