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

Do not allow running darwin/amd64 minikube binary on darwin/arm64 systems #11024

Merged
merged 6 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package cmd
import (
"flag"
"fmt"
"k8s.io/minikube/pkg/minikube/notify"
"k8s.io/minikube/pkg/version"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -93,6 +95,11 @@ func Execute() {
}
}

if runtime.GOOS == "darwin" && detect.IsAmd64M1Emulation() {
medyagh marked this conversation as resolved.
Show resolved Hide resolved
exit.Message(reason.WrongBinaryM1, "You are trying to run amd64 binary on M1 system. Please use darwin/arm64 binary instead (Download at {{.url}}.",
out.V{"url": notify.DownloadURL(version.GetVersion(), "darwin", "amd64")})
}

_, callingCmd := filepath.Split(os.Args[0])

if callingCmd == "kubectl" {
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95 // indirect
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
github.com/hooklift/iso9660 v0.0.0-20170318115843-1cf07e5970d8
github.com/intel-go/cpuid v0.0.0-20181003105527-1a4a6f06a1c6 // indirect
github.com/intel-go/cpuid v0.0.0-20181003105527-1a4a6f06a1c6
github.com/johanneswuerbach/nfsexports v0.0.0-20200318065542-c48c3734757f
github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c
github.com/juju/errors v0.0.0-20190806202954-0232dcc7464d // indirect
Expand All @@ -50,6 +50,7 @@ require (
github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d // indirect
github.com/juju/version v0.0.0-20180108022336-b64dbd566305 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/klauspost/cpuid v1.2.0
github.com/libvirt/libvirt-go v3.9.0+incompatible
github.com/machine-drivers/docker-machine-driver-vmware v0.1.1
github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.3 h1:dB4Bn0tN3wdCzQxnS8r06kV74qN/TAfaIS0bVE8h3jc=
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/cpuid v1.2.0 h1:NMpwD2G9JSFOE1/TJjGSo5zG7Yb2bTe7eq1jH+irmeE=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand Down Expand Up @@ -808,6 +809,7 @@ github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3
github.com/otiai10/copy v1.5.0 h1:SoXDGnlTUZoqB/wSuj/Y5L6T5i6iN4YRAcMCd+JnLNU=
github.com/otiai10/copy v1.5.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E=
Expand Down
8 changes: 8 additions & 0 deletions pkg/minikube/detect/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ limitations under the License.
package detect

import (
. "github.com/klauspost/cpuid"
"net/http"
"os"
"runtime"
"strings"
)

// IsMicrosoftWSL will return true if process is running in WSL in windows
Expand All @@ -43,3 +46,8 @@ func IsCloudShell() bool {
_, e := os.LookupEnv("CLOUDSHELL_ENVIRONMENT")
return e
}

// IsAmd64M1Emulation determines whether amd64 minikube binary is running on M1 mac in emulation mode
func IsAmd64M1Emulation() bool {
return runtime.GOARCH == "amd64" && strings.HasPrefix(CPU.BrandName, "VirtualApple")
}
13 changes: 13 additions & 0 deletions pkg/minikube/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,16 @@ func getTimeFromFileIfExists(path string) time.Time {
}
return timeInFile
}

// DownloadURL returns a URL to get minikube binary version ver for platform os/arch
func DownloadURL(ver, os, arch string) string {
medyagh marked this conversation as resolved.
Show resolved Hide resolved
if ver == "" || strings.HasSuffix(ver, "-unset") || os == "" || arch == "" {
return "https://github.com/kubernetes/minikube/releases"
}
sfx := ""
if os == "windows" {
sfx = ".exe"
}
return fmt.Sprintf("https://github.com/kubernetes/minikube/releases/download/%s/minikube-%s-%s%s",
ver, os, arch, sfx)
}
1 change: 1 addition & 0 deletions pkg/minikube/reason/reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ var (
Interrupted = Kind{ID: "MK_INTERRUPTED", ExitCode: ExProgramConflict}

WrongBinaryWSL = Kind{ID: "MK_WRONG_BINARY_WSL", ExitCode: ExProgramUnsupported}
WrongBinaryM1 = Kind{ID: "MK_WRONG_BINARY_M1", ExitCode: ExProgramUnsupported}

NewAPIClient = Kind{ID: "MK_NEW_APICLIENT", ExitCode: ExProgramError}
InternalAddonEnable = Kind{ID: "MK_ADDON_ENABLE", ExitCode: ExProgramError}
Expand Down