Merge pull request #15701 from spowelljr/checkBrewInstall

Check brew install paths for socket_vmnet
pull/15712/head
Medya Ghazizadeh 2023-01-25 13:57:33 -08:00 committed by GitHub
commit 6fdb2e1428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 110 additions and 67 deletions

View File

@ -281,8 +281,8 @@ func initNetworkingFlags() {
startCmd.Flags().Int(sshSSHPort, defaultSSHPort, "SSH port (ssh driver only)")
// socket vmnet
startCmd.Flags().String(socketVMnetClientPath, "/opt/socket_vmnet/bin/socket_vmnet_client", "Path to the socket vmnet client binary")
startCmd.Flags().String(socketVMnetPath, "/var/run/socket_vmnet", "Path to socket vmnet binary")
startCmd.Flags().String(socketVMnetClientPath, "", "Path to the socket vmnet client binary (QEMU driver only)")
startCmd.Flags().String(socketVMnetPath, "", "Path to socket vmnet binary (QEMU driver only)")
}
// ClusterFlagValue returns the current cluster name based on flags
@ -571,8 +571,8 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str
DisableOptimizations: viper.GetBool(disableOptimizations),
DisableMetrics: viper.GetBool(disableMetrics),
CustomQemuFirmwarePath: viper.GetString(qemuFirmwarePath),
SocketVMnetClientPath: viper.GetString(socketVMnetClientPath),
SocketVMnetPath: viper.GetString(socketVMnetPath),
SocketVMnetClientPath: detect.SocketVMNetClientPath(),
SocketVMnetPath: detect.SocketVMNetPath(),
StaticIP: viper.GetString(staticIP),
KubernetesConfig: config.KubernetesConfig{
KubernetesVersion: k8sVersion,

View File

@ -38,7 +38,6 @@ import (
"github.com/docker/machine/libmachine/ssh"
"github.com/docker/machine/libmachine/state"
"github.com/pkg/errors"
"github.com/spf13/viper"
pkgdrivers "k8s.io/minikube/pkg/drivers"
)
@ -56,30 +55,32 @@ type Driver struct {
EnginePort int
FirstQuery bool
Memory int
DiskSize int
CPU int
Program string
BIOS bool
CPUType string
MachineType string
Firmware string
Display bool
DisplayType string
Nographic bool
VirtioDrives bool
Network string
PrivateNetwork string
Boot2DockerURL string
CaCertPath string
PrivateKeyPath string
DiskPath string
CacheMode string
IOMode string
UserDataFile string
CloudConfigRoot string
LocalPorts string
MACAddress string
Memory int
DiskSize int
CPU int
Program string
BIOS bool
CPUType string
MachineType string
Firmware string
Display bool
DisplayType string
Nographic bool
VirtioDrives bool
Network string
PrivateNetwork string
Boot2DockerURL string
CaCertPath string
PrivateKeyPath string
DiskPath string
CacheMode string
IOMode string
UserDataFile string
CloudConfigRoot string
LocalPorts string
MACAddress string
SocketVMNetPath string
SocketVMNetClientPath string
}
func (d *Driver) GetMachineName() string {
@ -447,9 +448,8 @@ func (d *Driver) Start() error {
// If socket network, start with socket_vmnet.
startProgram := d.Program
if d.Network == "socket_vmnet" {
startProgram = viper.GetString("socket-vmnet-client-path")
socketVMnetPath := viper.GetString("socket-vmnet-path")
startCmd = append([]string{socketVMnetPath, d.Program}, startCmd...)
startProgram = d.SocketVMNetClientPath
startCmd = append([]string{d.SocketVMNetPath, d.Program}, startCmd...)
}
if stdout, stderr, err := cmdOutErr(startProgram, startCmd...); err != nil {

View File

@ -140,12 +140,49 @@ func SocketVMNetInstalled() bool {
if runtime.GOOS != "darwin" {
return false
}
_, err := os.Stat(viper.GetString("socket-vmnet-path"))
return SocketVMNetPath() != "" && SocketVMNetClientPath() != ""
}
// SocketVMNetPath returns the path of socket_vmnet (QEMU driver only)
func SocketVMNetPath() string {
p := viper.GetString("socket-vmnet-path")
if p != "" {
return p
}
return checkSocketVMNetInstallLocations("/var/run/socket_vmnet")
}
// SocketVMNetClientPath returns the path of socket_vmnet_client (QEMU driver only)
func SocketVMNetClientPath() string {
p := viper.GetString("socket-vmnet-client-path")
if p != "" {
return p
}
return checkSocketVMNetInstallLocations("/opt/socket_vmnet/bin/socket_vmnet_client")
}
// checkSocketVMNetInstallLocations accepts a relative file path
// checks the three possible socket_vmnet install locations for existence of the file path
// if the file path exists it returns the full path, otherwise if returns an empty string
func checkSocketVMNetInstallLocations(path string) string {
// source install, arm64 brew install, amd64 brew install
prefixes := []string{"", "/opt/homebrew", "/usr/local"}
for _, prefix := range prefixes {
fullPath := prefix + path
if fileExists(fullPath) {
return fullPath
}
}
return ""
}
func fileExists(filePath string) bool {
_, err := os.Stat(filePath)
if err == nil {
return true
}
if !errors.Is(err, os.ErrNotExist) {
klog.Warningf("failed to check for socket_vmnet: %v", err)
klog.Warningf("failed to check for existence of %s: %v", filePath, err)
}
return false
}

View File

@ -170,23 +170,25 @@ func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) {
StorePath: localpath.MiniPath(),
SSHUser: "docker",
},
Boot2DockerURL: download.LocalISOResource(cc.MinikubeISO),
DiskSize: cc.DiskSize,
Memory: cc.Memory,
CPU: cc.CPUs,
EnginePort: 2376,
FirstQuery: true,
DiskPath: filepath.Join(localpath.MiniPath(), "machines", name, fmt.Sprintf("%s.img", name)),
Program: qemuSystem,
BIOS: runtime.GOARCH != "arm64",
MachineType: qemuMachine,
CPUType: qemuCPU,
Firmware: qemuFirmware,
VirtioDrives: false,
Network: cc.Network,
CacheMode: "default",
IOMode: "threads",
MACAddress: mac,
Boot2DockerURL: download.LocalISOResource(cc.MinikubeISO),
DiskSize: cc.DiskSize,
Memory: cc.Memory,
CPU: cc.CPUs,
EnginePort: 2376,
FirstQuery: true,
DiskPath: filepath.Join(localpath.MiniPath(), "machines", name, fmt.Sprintf("%s.img", name)),
Program: qemuSystem,
BIOS: runtime.GOARCH != "arm64",
MachineType: qemuMachine,
CPUType: qemuCPU,
Firmware: qemuFirmware,
VirtioDrives: false,
Network: cc.Network,
CacheMode: "default",
IOMode: "threads",
MACAddress: mac,
SocketVMNetPath: cc.SocketVMnetPath,
SocketVMNetClientPath: cc.SocketVMnetClientPath,
}, nil
}

View File

@ -105,8 +105,8 @@ minikube start [flags]
--qemu-firmware-path string Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\Program Files\qemu\share
--registry-mirror strings Registry mirrors to pass to the Docker daemon
--service-cluster-ip-range string The CIDR to be used for service cluster IPs. (default "10.96.0.0/12")
--socket-vmnet-client-path string Path to the socket vmnet client binary (default "/opt/socket_vmnet/bin/socket_vmnet_client")
--socket-vmnet-path string Path to socket vmnet binary (default "/var/run/socket_vmnet")
--socket-vmnet-client-path string Path to the socket vmnet client binary (QEMU driver only)
--socket-vmnet-path string Path to socket vmnet binary (QEMU driver only)
--ssh-ip-address string IP address (ssh driver only)
--ssh-key string SSH key (ssh driver only)
--ssh-port int SSH port (ssh driver only) (default 22)

View File

@ -470,10 +470,10 @@
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "Überschreibe das Image, auch wenn ein Image mit dem gleichen Image:Tag-Namen existiert",
"Path to socket vmnet binary": "",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "Pfad des zu verwendenden Dockerfiles (optional)",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "",
"Path to the socket vmnet client binary": "",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "",
"Paused {{.count}} containers": "{{.count}} Container pausiert",
"Paused {{.count}} containers in: {{.namespaces}}": "{{.count}} Container pausiert in: {{.namespaces}}",

View File

@ -477,10 +477,10 @@
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "",
"Path to socket vmnet binary": "",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "",
"Path to the socket vmnet client binary": "",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "",
"Paused {{.count}} containers": "",
"Paused {{.count}} containers in: {{.namespaces}}": "",

View File

@ -458,9 +458,11 @@
"Outputs the licenses of dependencies to a directory": "Copie les licences des dépendances dans un répertoire",
"Overwrite image even if same image:tag name exists": "Écraser l'image même si la même image:balise existe",
"Path to socket vmnet binary": "Chemin d'accès au binaire socket vmnet",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "Chemin d'accès au Dockerfile à utiliser (facultatif)",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "Chemin d'accès au fichier du micrologiciel qemu. Valeurs par défaut : pour Linux, l'emplacement du micrologiciel par défaut. Pour macOS, l'emplacement d'installation de brew. Pour Windows, C:\\Program Files\\qemu\\share",
"Path to the socket vmnet client binary": "Chemin d'accès au binaire socket vmnet",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "Pause",
"Paused {{.count}} containers": "{{.count}} conteneurs suspendus",
"Paused {{.count}} containers in: {{.namespaces}}": "{{.count}} conteneurs suspendus dans : {{.namespaces}}",

View File

@ -443,9 +443,11 @@
"Outputs the licenses of dependencies to a directory": "依存関係のライセンスをディレクトリーに出力します",
"Overwrite image even if same image:tag name exists": "同じ image:tag 名が存在していてもイメージを上書きします",
"Path to socket vmnet binary": "socket vmnet バイナリーへのパス",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "使用する Dockerfile へのパス (任意)",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "qemu ファームウェアファイルへのパス。デフォルト: Linux の場合、デフォルトのファームウェアの場所。macOS の場合、brew のインストール場所。Windows の場合、C:\\Program Files\\qemu\\share",
"Path to the socket vmnet client binary": "socket vmnet クライアントバイナリーへのパス",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "一時停止",
"Paused {{.count}} containers": "{{.count}} 個のコンテナーを一時停止しました",
"Paused {{.count}} containers in: {{.namespaces}}": "{{.namespaces}} に存在する {{.count}} 個のコンテナーを一時停止しました",

View File

@ -490,10 +490,10 @@
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "",
"Path to socket vmnet binary": "",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "",
"Path to the socket vmnet client binary": "",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "",
"Paused {{.count}} containers": "",
"Paused {{.count}} containers in: {{.namespaces}}": "",

View File

@ -484,10 +484,10 @@
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "Nadpisuje obraz nawet jeśli istnieje obraz o tej samej nazwie i tagu.",
"Path to socket vmnet binary": "",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "Ścieżka pliku Dockerfile, którego należy użyć (opcjonalne)",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "",
"Path to the socket vmnet client binary": "",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "Stop",
"Paused {{.count}} containers": "Zatrzymane kontenery: {{.count}}",
"Paused {{.count}} containers in: {{.namespaces}}": "Zatrzymane kontenery: {{.count}} w przestrzeniach nazw: {{.namespaces}}",

View File

@ -440,10 +440,10 @@
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "",
"Path to socket vmnet binary": "",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "",
"Path to the socket vmnet client binary": "",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "",
"Paused {{.count}} containers": "",
"Paused {{.count}} containers in: {{.namespaces}}": "",

View File

@ -440,10 +440,10 @@
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "",
"Path to socket vmnet binary": "",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "",
"Path to the socket vmnet client binary": "",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "",
"Paused {{.count}} containers": "",
"Paused {{.count}} containers in: {{.namespaces}}": "",

View File

@ -557,10 +557,10 @@
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "",
"Path to socket vmnet binary": "",
"Path to socket vmnet binary (QEMU driver only)": "",
"Path to the Dockerfile to use (optional)": "",
"Path to the qemu firmware file. Defaults: For Linux, the default firmware location. For macOS, the brew installation location. For Windows, C:\\Program Files\\qemu\\share": "",
"Path to the socket vmnet client binary": "",
"Path to the socket vmnet client binary (QEMU driver only)": "",
"Pause": "暂停",
"Paused kubelet and {{.count}} containers": "已暂停 kubelet 和 {{.count}} 个容器",
"Paused kubelet and {{.count}} containers in: {{.namespaces}}": "已暂停 {{.namespaces}} 中的 kubelet 和 {{.count}} 个容器",