warn users if using VirtualBox on macOS 13+

pull/15624/head
Steven Powell 2023-01-10 10:14:27 -08:00
parent 46bccc7def
commit eb884228a4
2 changed files with 34 additions and 0 deletions

View File

@ -300,6 +300,7 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
klog.Errorf("Error autoSetOptions : %v", err)
}
virtualBoxMacOS13PlusWarning(driverName)
validateFlags(cmd, driverName)
validateUser(driverName)
if driverName == oci.Docker {
@ -373,6 +374,20 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
}, nil
}
func virtualBoxMacOS13PlusWarning(driverName string) {
if driverName != "virtualbox" || !detect.MacOS13Plus() {
return
}
driver := "hyperkit"
if runtime.GOARCH == "arm64" {
driver = "qemu"
}
out.WarningT(`Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. We recommend using the {{.driver}} driver: https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/
For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274
`, out.V{"driver": driver})
}
func validateBuiltImageVersion(r command.Runner) {
res, err := r.RunCmd(exec.Command("cat", "/version.json"))
if err != nil {

View File

@ -23,6 +23,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"github.com/klauspost/cpuid"
@ -165,3 +166,21 @@ func CgroupDriver() string {
return constants.DefaultCgroupDriver // try with default rather than just give up
}
}
// MacOS13Plus returns if the current machine is running macOS 13+
func MacOS13Plus() bool {
if runtime.GOOS != "darwin" {
return false
}
o, err := exec.Command("sw_vers", "-productVersion").Output()
if err != nil {
klog.Warningf("failed to get macOS version: %v", err)
return false
}
major, err := strconv.Atoi(strings.Split(string(o), ".")[0])
if err != nil {
klog.Warningf("failed to convert macOS version to int: %v", err)
return false
}
return major >= 13
}