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

Conversation

p2c2e
Copy link
Contributor

@p2c2e p2c2e commented Jan 27, 2023

fixes #11510
resolves #12729 (was closed without fix)

Rather than assume 192.168.64.1 - which might not be true if dhcpd lease is already active for some other VM etc.
We try to use the gateway IP is usually the hostip with the last octet as "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.
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"
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.

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 ...

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 :)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 27, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: p2c2e
Once this PR has been reviewed and has the lgtm label, please assign sharifelgamal for approval by writing /assign @sharifelgamal in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 27, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @p2c2e. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 27, 2023
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@@ -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 :)

@p2c2e p2c2e requested review from medyagh and removed request for prezha and sharifelgamal January 28, 2023 13:27
@p2c2e
Copy link
Contributor Author

p2c2e commented Feb 1, 2023

Hi @medyagh - Gentle nudge on this :) This will change will help lot of folks + help me avoid keeping a custom version of minikube! Thank You

@p2c2e
Copy link
Contributor Author

p2c2e commented Feb 14, 2023

/cc @sharifelgamal
/cc @prezha

Not sure if this is the right thing to do - Trying to bump this issues - since the reviewers were removed when requesting 're-review' and this is stuck in 'Changes requested'. Thanks!

@medyagh
Copy link
Member

medyagh commented Feb 15, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 15, 2023
@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15720) |
+----------------+----------+---------------------+
| minikube start | 54.0s    | 52.5s               |
| enable ingress | 26.8s    | 25.5s               |
+----------------+----------+---------------------+

Times for minikube ingress: 24.2s 28.2s 29.2s 27.6s 24.7s
Times for minikube (PR 15720) ingress: 27.6s 23.7s 28.2s 24.2s 23.7s

Times for minikube start: 54.1s 53.6s 54.3s 53.8s 54.4s
Times for minikube (PR 15720) start: 57.7s 51.6s 53.6s 50.1s 49.6s

docker driver with docker runtime

+-------------------+----------+---------------------+
|      COMMAND      | MINIKUBE | MINIKUBE (PR 15720) |
+-------------------+----------+---------------------+
| minikube start    | 26.3s    | 26.3s               |
| ⚠️  enable ingress | 20.4s    | 26.9s ⚠️             |
+-------------------+----------+---------------------+

Times for minikube ingress: 21.1s 21.1s 20.1s 20.1s 19.6s
Times for minikube (PR 15720) ingress: 50.1s 22.0s 21.0s 21.1s 20.1s

Times for minikube start: 27.5s 25.9s 26.3s 26.2s 25.6s
Times for minikube (PR 15720) start: 26.1s 25.9s 26.5s 26.9s 26.2s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15720) |
+----------------+----------+---------------------+
| minikube start | 22.2s    | 22.1s               |
| enable ingress | 36.6s    | 36.4s               |
+----------------+----------+---------------------+

Times for minikube (PR 15720) start: 22.6s 22.8s 21.8s 21.3s 22.0s
Times for minikube start: 22.4s 22.0s 22.7s 22.2s 21.7s

Times for minikube ingress: 19.6s 31.5s 79.5s 32.5s 19.5s
Times for minikube (PR 15720) ingress: 78.6s 19.6s 31.6s 19.5s 32.6s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
Hyperkit_macOS TestFunctional/parallel/ConfigCmd (gopogh) 23.49 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressDNSAddonActivation (gopogh) 98.76 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddonActivation (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddons (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/StartLegacyK8sCluster (gopogh) 100.00 (chart)
Docker_macOS TestKubernetesUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestMissingContainerUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestRunningBinaryUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/AddonExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/DeployApp (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/EnableAddonWhileActive (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/FirstStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/SecondStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/UserAppExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStoppedBinaryUpgrade/Upgrade (gopogh) 100.00 (chart)
KVM_Linux_containerd TestPreload (gopogh) 100.00 (chart)

To see the flake rates of all tests by environment, click here.

@medyagh
Copy link
Member

medyagh commented Feb 15, 2023

@p2c2e thank you for your patience on this, we have a long queue of PRs to review :) but the test look good

@p2c2e
Copy link
Contributor Author

p2c2e commented Feb 16, 2023

@p2c2e thank you for your patience on this, we have a long queue of PRs to review :) but the test look good

Thanks - I completely understand. What is next though? As per the bot messages - I see need for "lgtm" before I can assign the PR to @sharifelgamal ; ( I sorely need a 'state diagram" to visualize the flow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants