diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index 1fe6de5868..ef1314e7a6 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -35,6 +35,7 @@ import ( "github.com/pingcap/tiup/pkg/environment" "github.com/pingcap/tiup/pkg/logger/log" "github.com/pingcap/tiup/pkg/meta" + "github.com/pingcap/tiup/pkg/repository" "github.com/pingcap/tiup/pkg/set" "github.com/pingcap/tiup/pkg/utils" ) @@ -270,7 +271,10 @@ func (m *Manager) Deploy( case spec.ComponentTiSpark: env := environment.GlobalEnv() var sparkVer utils.Version - if sparkVer, _, iterErr = env.V1Repository().LatestStableVersion(spec.ComponentSpark, false); iterErr != nil { + if sparkVer, _, iterErr = env.V1Repository().WithOptions(repository.Options{ + GOOS: inst.OS(), + GOARCH: inst.Arch(), + }).LatestStableVersion(spec.ComponentSpark, false); iterErr != nil { return } t = t.DeploySpark(inst, sparkVer.String(), "" /* default srcPath */, deployDir) diff --git a/pkg/cluster/manager/upgrade.go b/pkg/cluster/manager/upgrade.go index 023dc73852..c45eeff6ca 100644 --- a/pkg/cluster/manager/upgrade.go +++ b/pkg/cluster/manager/upgrade.go @@ -30,6 +30,7 @@ import ( "github.com/pingcap/tiup/pkg/environment" "github.com/pingcap/tiup/pkg/logger/log" "github.com/pingcap/tiup/pkg/meta" + "github.com/pingcap/tiup/pkg/repository" "github.com/pingcap/tiup/pkg/utils" "golang.org/x/mod/semver" ) @@ -121,7 +122,10 @@ func (m *Manager) Upgrade(name string, clusterVersion string, opt operator.Optio switch inst.ComponentName() { case spec.ComponentTiSpark: env := environment.GlobalEnv() - sparkVer, _, err := env.V1Repository().LatestStableVersion(spec.ComponentSpark, false) + sparkVer, _, err := env.V1Repository().WithOptions(repository.Options{ + GOOS: inst.OS(), + GOARCH: inst.Arch(), + }).LatestStableVersion(spec.ComponentSpark, false) if err != nil { return err } diff --git a/pkg/cluster/task/copy_component.go b/pkg/cluster/task/copy_component.go index 208060af06..519a224189 100644 --- a/pkg/cluster/task/copy_component.go +++ b/pkg/cluster/task/copy_component.go @@ -19,6 +19,7 @@ import ( "github.com/pingcap/tiup/pkg/cluster/spec" "github.com/pingcap/tiup/pkg/environment" + "github.com/pingcap/tiup/pkg/repository" ) // CopyComponent is used to copy all files related the specific version a component @@ -38,7 +39,10 @@ func (c *CopyComponent) Execute(ctx context.Context) error { // If the version is not specified, the last stable one will be used if c.version == "" { env := environment.GlobalEnv() - ver, _, err := env.V1Repository().LatestStableVersion(c.component, false) + ver, _, err := env.V1Repository().WithOptions(repository.Options{ + GOOS: c.os, + GOARCH: c.arch, + }).LatestStableVersion(c.component, false) if err != nil { return err } diff --git a/pkg/cluster/task/download.go b/pkg/cluster/task/download.go index fb264703e4..846fc66c8b 100644 --- a/pkg/cluster/task/download.go +++ b/pkg/cluster/task/download.go @@ -19,6 +19,7 @@ import ( operator "github.com/pingcap/tiup/pkg/cluster/operation" "github.com/pingcap/tiup/pkg/environment" + "github.com/pingcap/tiup/pkg/repository" ) // Downloader is used to download the specific version of a component from @@ -45,7 +46,10 @@ func (d *Downloader) Execute(_ context.Context) error { // If the version is not specified, the last stable one will be used if d.version == "" { env := environment.GlobalEnv() - ver, _, err := env.V1Repository().LatestStableVersion(d.component, false) + ver, _, err := env.V1Repository().WithOptions(repository.Options{ + GOOS: d.os, + GOARCH: d.arch, + }).LatestStableVersion(d.component, false) if err != nil { return err } diff --git a/pkg/repository/v1_repository.go b/pkg/repository/v1_repository.go index f0661e84e7..f7efa9d62c 100644 --- a/pkg/repository/v1_repository.go +++ b/pkg/repository/v1_repository.go @@ -86,6 +86,11 @@ func NewV1Repo(mirror Mirror, opts Options, local v1manifest.LocalManifests) *V1 const maxTimeStampSize uint = 1024 const maxRootSize uint = 1024 * 1024 +// WithOptions clone a new V1Repository with given options +func (r *V1Repository) WithOptions(opts Options) *V1Repository { + return NewV1Repo(r.Mirror(), opts, r.Local()) +} + // Mirror returns Mirror func (r *V1Repository) Mirror() Mirror { return r.mirror