Skip to content

Commit

Permalink
Fix the issue that tiup-cluster can't deploy arm64 binary (#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklove committed Mar 19, 2021
1 parent 0a902aa commit a7ec692
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
6 changes: 5 additions & 1 deletion pkg/cluster/manager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/utils"
Expand Down Expand Up @@ -269,7 +270,10 @@ func (m *Manager) Deploy(
case spec.ComponentTiSpark:
env := environment.GlobalEnv()
var sparkVer pkgver.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)
Expand Down
6 changes: 5 additions & 1 deletion pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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/version"
"golang.org/x/mod/semver"
)
Expand Down Expand Up @@ -114,7 +115,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
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/cluster/task/copy_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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
Expand All @@ -37,7 +38,10 @@ func (c *CopyComponent) Execute(ctx *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
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/cluster/task/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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
Expand All @@ -44,7 +45,10 @@ func (d *Downloader) Execute(_ *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
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/repository/v1_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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
Expand Down

0 comments on commit a7ec692

Please sign in to comment.