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

Check brew install paths for socket_vmnet #15701

Merged
merged 4 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
56 changes: 28 additions & 28 deletions pkg/drivers/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
41 changes: 39 additions & 2 deletions pkg/minikube/detect/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
spowelljr marked this conversation as resolved.
Show resolved Hide resolved
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
}
Expand Down
36 changes: 19 additions & 17 deletions pkg/minikube/registry/drvs/qemu2/qemu2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions site/content/en/docs/commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down
4 changes: 2 additions & 2 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}": "",
Expand Down
2 changes: 2 additions & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down
2 changes: 2 additions & 0 deletions translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}} 個のコンテナーを一時停止しました",
Expand Down
4 changes: 2 additions & 2 deletions translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}": "",
Expand Down
4 changes: 2 additions & 2 deletions translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down
4 changes: 2 additions & 2 deletions translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}": "",
Expand Down
Loading