From 517f53567d1ee554b4b3405e59d363b73e6a57cf 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 db7cae12f9..4de7c4afcd 100644 --- a/pkg/cluster/task/builder.go +++ b/pkg/cluster/task/builder.go @@ -24,9 +24,11 @@ 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" "github.com/pingcap/tiup/pkg/logger/log" "github.com/pingcap/tiup/pkg/meta" "github.com/pingcap/tiup/pkg/proxy" + "github.com/pingcap/tiup/pkg/utils" ) // Builder is used to build TiUP task @@ -230,10 +232,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,