From f7a536b3ff763337644a716378b6ac2775c6ab16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qi=CE=BC=24hi=D0=AFu=C3=AD?= <39378935+srstack@users.noreply.github.com> Date: Fri, 7 Jan 2022 11:48:37 +0800 Subject: [PATCH] cluster: nightly version could not be compared (#1702) --- pkg/cluster/task/builder.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/task/builder.go b/pkg/cluster/task/builder.go index 3eb7829d74..e89f3d834b 100644 --- a/pkg/cluster/task/builder.go +++ b/pkg/cluster/task/builder.go @@ -23,10 +23,12 @@ import ( operator "github.com/pingcap/tiup/pkg/cluster/operation" "github.com/pingcap/tiup/pkg/cluster/spec" "github.com/pingcap/tiup/pkg/crypto" + "github.com/pingcap/tiup/pkg/environment" logprinter "github.com/pingcap/tiup/pkg/logger/printer" "github.com/pingcap/tiup/pkg/meta" "github.com/pingcap/tiup/pkg/proxy" "github.com/pingcap/tiup/pkg/tui" + "github.com/pingcap/tiup/pkg/utils" ) // Builder is used to build TiUP task @@ -242,10 +244,31 @@ func (b *Builder) BackupComponent(component, fromVer string, host, deployDir str // InitConfig appends a CopyComponent task to the current task collection func (b *Builder) InitConfig(clusterName, clusterVersion string, specManager *spec.SpecManager, inst spec.Instance, deployUser string, ignoreCheck bool, paths meta.DirPaths) *Builder { + // get nightly version + var componentVersion utils.Version + meta := specManager.NewMetadata() + + // full version + componentVersion = utils.Version(clusterVersion) + if err := specManager.Metadata(clusterName, meta); err == nil { + // get nightly version + if clusterVersion == utils.NightlyVersionAlias { + componentVersion, _, err = environment.GlobalEnv().V1Repository().LatestNightlyVersion(inst.ComponentName()) + if err != nil { + componentVersion = utils.Version(clusterVersion) + } + } + + // dm cluster does not require a full nightly version + if meta.GetTopology().Type() == spec.TopoTypeDM { + componentVersion = utils.Version(clusterVersion) + } + } + b.tasks = append(b.tasks, &InitConfig{ specManager: specManager, clusterName: clusterName, - clusterVersion: clusterVersion, + clusterVersion: string(componentVersion), instance: inst, deployUser: deployUser, ignoreCheck: ignoreCheck,