Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster: nightly version could not be compared #1702

Merged
merged 10 commits into from
Jan 7, 2022
25 changes: 24 additions & 1 deletion pkg/cluster/task/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down