diff --git a/pkg/cluster/manager/patch.go b/pkg/cluster/manager/patch.go index 087ded0ccb..e4c5669f29 100644 --- a/pkg/cluster/manager/patch.go +++ b/pkg/cluster/manager/patch.go @@ -105,7 +105,7 @@ func (m *Manager) Patch(name string, packagePath string, opt operator.Options, o return nil } // TBD: should patch be treated as an upgrade? - return operator.Upgrade(ctx, topo, opt, tlsCfg, base.Version, false) + return operator.Upgrade(ctx, topo, opt, tlsCfg, base.Version, base.Version) }). Build() diff --git a/pkg/cluster/manager/reload.go b/pkg/cluster/manager/reload.go index 21ec4f6b7a..226c66535e 100644 --- a/pkg/cluster/manager/reload.go +++ b/pkg/cluster/manager/reload.go @@ -124,7 +124,7 @@ func (m *Manager) Reload(name string, gOpt operator.Options, skipRestart, skipCo return err } b.Func("Upgrade Cluster", func(ctx context.Context) error { - return operator.Upgrade(ctx, topo, gOpt, tlsCfg, base.Version, false) + return operator.Upgrade(ctx, topo, gOpt, tlsCfg, base.Version, base.Version) }) } diff --git a/pkg/cluster/manager/upgrade.go b/pkg/cluster/manager/upgrade.go index fe76ff5ac5..32354d4f7b 100644 --- a/pkg/cluster/manager/upgrade.go +++ b/pkg/cluster/manager/upgrade.go @@ -237,7 +237,7 @@ Do you want to continue? [y/N]:`, if offline { return nil } - return operator.Upgrade(ctx, topo, opt, tlsCfg, base.Version, true) + return operator.Upgrade(ctx, topo, opt, tlsCfg, base.Version, clusterVersion) }). Build() diff --git a/pkg/cluster/operation/upgrade.go b/pkg/cluster/operation/upgrade.go index 80ee1679b2..5f4ab04b3f 100644 --- a/pkg/cluster/operation/upgrade.go +++ b/pkg/cluster/operation/upgrade.go @@ -46,7 +46,7 @@ func Upgrade( options Options, tlsCfg *tls.Config, currentVersion string, - isUpgrade bool, + targetVersion string, ) error { roleFilter := set.NewStringSet(options.Roles...) nodeFilter := set.NewStringSet(options.Nodes...) @@ -109,7 +109,7 @@ func Upgrade( endpoints = append(endpoints, utils.JoinHostPort(db.GetManageHost(), db.StatusPort)) } - if isUpgrade && tidbver.TiDBSupportUpgradeAPI(currentVersion) { + if currentVersion != targetVersion && tidbver.TiDBSupportUpgradeAPI(currentVersion) && tidbver.TiDBSupportUpgradeAPI(targetVersion) { tidbClient = api.NewTiDBClient(ctx, endpoints, 10*time.Second, tlsCfg) err = tidbClient.StartUpgrade() if err != nil { @@ -198,7 +198,7 @@ func Upgrade( switch component.Name() { case spec.ComponentTiDB: - if isUpgrade && tidbver.TiDBSupportUpgradeAPI(currentVersion) { + if currentVersion != targetVersion && tidbver.TiDBSupportUpgradeAPI(currentVersion) && tidbver.TiDBSupportUpgradeAPI(targetVersion) { err = tidbClient.FinishUpgrade() if err != nil { return err diff --git a/pkg/tidbver/tidbver.go b/pkg/tidbver/tidbver.go index 18cc53e74f..eae857f78e 100644 --- a/pkg/tidbver/tidbver.go +++ b/pkg/tidbver/tidbver.go @@ -28,7 +28,9 @@ func TiDBSupportSecureBoot(version string) bool { // TiDBSupportUpgradeAPI return if given version of TiDB support upgrade API func TiDBSupportUpgradeAPI(version string) bool { - return semver.Compare(version, "v7.4.0") >= 0 || strings.Contains(version, "nightly") + return semver.Compare(version, "v7.4.0") >= 0 || + (semver.MajorMinor(version) == "v7.1" && semver.Compare(version, "v7.1.2") >= 0) || + strings.Contains(version, "nightly") } // TiKVSupportAdvertiseStatusAddr return if given version of TiKV support --advertise-status-addr