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

Infer HyperKit HostIP as Gateway rather than hardcode to 192.168.64.1  #15720

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion pkg/minikube/cluster/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ func HostIP(host *host.Host, clusterName string) (net.IP, error) {

return net.ParseIP(ip), nil
case driver.HyperKit:
return net.ParseIP("192.168.64.1"), nil
vmIPString, _ := host.Driver.GetIP()
gatewayIPString := vmIPString[:strings.LastIndex(vmIPString, ".")+1] + "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to minikube, can you please put the output of minikube before/after this PR ?

and does this break normal users who currently dont have an issue ?
please comment what this code does? and how about using a library that handles incrementing the IPS instead of using string.

Copy link
Contributor Author

@p2c2e p2c2e Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This PR specifically applies to MacOS users who have chosen Hyperkit (specified or since it is default). The code path does NOT affect any other combination of users.
  2. What does the code do?
    90% of the users on MacOS using Hyperkit driver will have issues with mounting a filesystem (or anything that requires access to host from within VM). Unless the user is using Minikube or similar tools first time, there is a strong chance that the IP assigned to the VM will NOT be in 192.168.64.X range. On the host, we can check all existing dhcp leases on Mac in /var/db/dhcpd_leases. For regular users, the dhcp subnet assigned by Hyperkit will be a different range. In following example, I was assigned dhcpd lease with host IP of "192.168.205.5" and gateway/nameserver will then be "192.168.205.1"
  3. Before PR* : attempting to mount a filesystem with “minikube mount” will fail via timeout since it will be trying on some non-existent IP.
$ minikube mount /tmp:/myhosttmp --v=7
📁  Mounting host path /tmp into VM as /myhosttmp ...
    ▪ Mount type:
    ▪ User ID:      docker
    ▪ Group ID:     docker
    ▪ Version:      9p2000.L
    ▪ Message Size: 262144
    ▪ Options:      map[]
    ▪ Bind Address: 192.168.64.1:53740            <<<< PROBLEM: This IP is hardcoded and not right…..
🚀  Userspace file server: ufs starting
🛑  Userspace file server is shutdown

❌  Exiting due to GUEST_MOUNT_COULD_NOT_CONNECT: /bin/bash -c "sudo mount -t 9p -o dfltgid=$(grep ^docker: /etc/group | cut -d: -f3),dfltuid=$(id -u docker),msize=262144,port=53740,trans=tcp,version=9p2000.L 192.168.64.1 /myhosttmp": Process exited with status 32
stdout:

stderr:
mount: /myhosttmp: mount(2) system call failed: Connection timed out.
  1. After PR : attempting to mount a filesystem should just work… See below verbose log..
$ minikube mount /tmp:/myhosttmp --v=7

📁  Mounting host path /tmp into VM as /myhosttmp ...
    ▪ Mount type:   
    ▪ User ID:      docker
    ▪ Group ID:     docker
    ▪ Version:      9p2000.L
    ▪ Message Size: 262144
    ▪ Options:      map[]
    ▪ Bind Address: 192.168.205.1:53935              <<<< SOLVED : Uses correct ‘inferred’ IP. Works …
🚀  Userspace file server: ufs starting
✅  Successfully mounted /tmp to /myhosttmp

📌  NOTE: This process must stay alive for the mount to be accessible ...
  1. We cannot 'increment' IPs etc., in this case because it HAS to be a "1" for routing/gateway to the host. Any other solution will be more complicated.

Hope this clarifies. Seems like lot of folks have this issue and this PR will help them :)

return net.ParseIP(gatewayIPString), nil
case driver.VMware:
vmIPString, err := host.Driver.GetIP()
if err != nil {
Expand Down