Skip to content

Commit

Permalink
Merge 8626df3 into 4f5d9e3
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaaaaaang authored Oct 17, 2023
2 parents 4f5d9e3 + 8626df3 commit 96924dc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/cluster/manager/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/manager/reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/operation/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pkg/tidbver/tidbver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96924dc

Please sign in to comment.