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

More robust MAC address matching #19750

Merged
merged 1 commit into from
Oct 14, 2024
Merged

More robust MAC address matching #19750

merged 1 commit into from
Oct 14, 2024

Conversation

nirs
Copy link
Contributor

@nirs nirs commented Oct 4, 2024

On darwin bootp uses non-standard MAC address format[1]:
"8e:1:99:9c:54:b1" instead of "8e:01:99:9c:54:b1". We fixed this by
trimming leading "0" in the string before looking up the IP address.

There are several issues with the current code:

  • Fragile, will break if bootp changes the format (unlikely)
  • Fixing the wrong place, the drivers should not care about the MAC
    address format.
  • The tests were confusing, showing that we can match standard MAC
    addresses while the actual code could match only non-standard bootp
    addresses.
  • Logging wrong MAC address since we trimmed leading zeros before
    logging

This change replace trimming leading zeros with parsing MAC address
strings and comparing the bytes. The test includes now both standard and
non-standard MAC addresses.

[1] https://openradar.appspot.com/FB15382970

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 4, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @nirs. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 4, 2024
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@nirs
Copy link
Contributor Author

nirs commented Oct 4, 2024

I see that this is already fixed earlier:

	// Need to strip 0's
	mac = pkgdrivers.TrimMacAddress(mac)
	if err := d.setupIP(mac); err != nil {
		return err
	}

Probably when this failed the reason was different (firewall or evil corp vpn software). When I came back to look at this, I found the trimmed addresses in the dhcp leases.

But the tests are confusing, not showing the actual entries and trimmed mac addresses, and the current code will break if bootp fixes this issue and start formatting mac addresses like other tools.

If we replace trimming with parsing, we don't need to care how bootp or other programs format hw_address.

pkg/drivers/common.go Outdated Show resolved Hide resolved
On darwin bootp uses non-standard MAC address format[1]:
"8e:1:99:9c:54:b1" instead of "8e:01:99:9c:54:b1". We fixed this by
trimming leading "0" in the string before looking up the IP address.

There are several issues with the current code:
- Fragile, will break if bootp changes the format (unlikely)
- Fixing the wrong place, the drivers should not care about the MAC
  address format.
- The tests were confusing, showing that we can match standard MAC
  addresses while the actual code could match only non-standard bootp
  addresses.
- Logging wrong MAC address since we trimmed leading zeros before
  logging

This change replace trimming leading zeros with parsing MAC address
strings and comparing the bytes. The test includes now both standard and
non-standard MAC addresses.

[1] https://openradar.appspot.com/FB15382970
@nirs nirs changed the title Fix random failure to find IP address on macOS More robust MAC address matching Oct 5, 2024
@nirs
Copy link
Contributor Author

nirs commented Oct 5, 2024

@spowelljr can you review? you added this in 8c12c40.

@@ -190,7 +189,7 @@ func fixMachinePermissions(path string) error {
type DHCPEntry struct {
Name string
IPAddress string
HWAddress string
HWAddress net.HardwareAddr
Copy link
Member

Choose a reason for hiding this comment

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

thank you ! I like that

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh, nirs

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 9, 2024
@medyagh
Copy link
Member

medyagh commented Oct 9, 2024

/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 Oct 9, 2024
@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 19750) |
+----------------+----------+---------------------+
| minikube start | 50.9s    | 49.7s               |
| enable ingress | 16.0s    | 18.0s               |
+----------------+----------+---------------------+

Times for minikube start: 49.1s 51.3s 51.7s 52.3s 50.2s
Times for minikube (PR 19750) start: 47.7s 51.3s 52.7s 49.1s 47.7s

Times for minikube ingress: 15.0s 18.5s 16.0s 14.5s 16.0s
Times for minikube (PR 19750) ingress: 15.0s 19.1s 18.5s 18.6s 19.0s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 19750) |
+----------------+----------+---------------------+
| minikube start | 21.9s    | 22.8s               |
| enable ingress | 12.7s    | 12.8s               |
+----------------+----------+---------------------+

Times for minikube start: 22.5s 23.2s 22.3s 21.5s 20.1s
Times for minikube (PR 19750) start: 23.7s 21.5s 24.0s 20.4s 24.1s

Times for minikube ingress: 12.3s 13.8s 12.3s 12.8s 12.3s
Times for minikube (PR 19750) ingress: 12.3s 13.3s 12.8s 13.3s 12.3s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 19750) |
+----------------+----------+---------------------+
| minikube start | 22.9s    | 22.4s               |
| enable ingress | 36.2s    | 23.0s               |
+----------------+----------+---------------------+

Times for minikube start: 24.0s 22.7s 22.6s 22.7s 22.7s
Times for minikube (PR 19750) start: 22.8s 22.5s 22.1s 21.2s 23.1s

Times for minikube ingress: 40.3s 39.8s 38.8s 39.3s 22.8s
Times for minikube (PR 19750) ingress: 22.8s 22.8s 23.3s 23.3s 22.8s

@minikube-pr-bot
Copy link

Here are the number of top 10 failed tests in each environments with lowest flake rate.

Environment Test Name Flake Rate

Besides the following environments also have failed tests:

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

@medyagh medyagh merged commit c090344 into kubernetes:master Oct 14, 2024
25 of 40 checks passed
@nirs nirs deleted the bootp-bug branch October 14, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants