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
Support more than 99 nodes in NixOS tests & export toHex and toBase #85635
Support more than 99 nodes in NixOS tests & export toHex and toBase #85635
Conversation
@GrahamcOfBorg test networking |
@GrahamcOfBorg test networking.dhcpSimple |
@GrahamcOfBorg test networking.networkd |
`toHex` converts the given positive integer to a string of the hexadecimal representation of that integer. For example: ``` toHex 0 => "0" toHex 16 => "10" toHex 250 => "FA" ``` `toBase base i` converts the positive integer `i` to a list of it digits in the given `base`. For example: ``` toBase 10 123 => [ 1 2 3 ] toBase 2 6 => [ 1 1 0 ] toBase 16 250 => [ 15 10 ] ```
This modifies the `router` to not give out a range of IP addresses but only give out a fixed address based on the MAC address using the `services.dhcpd4.machines` option. To get access to the MAC address the `qemuNicMac` function is defined and exported from `qemu-flags.nix`.
This makes the type of these functions more apparent from the name.
c12a9d9
to
6e7822b
Compare
@GrahamcOfBorg test networking.networkd |
@GrahamcOfBorg test networking.networkd.dhcpSimple |
Maybe it's better to assert that there aren't more than 99 nodes? If you have that many nodes you have a big problem, since it's going to be superslow and take a huge amount of memory. |
No. as Bas already noted this starts breaking at 10 nodes; not 100 without this fix. Adding an assertion |
Motivation for this change
The current
zeroPad
function, which determines the MAC address of each QEMU VM in NixOS tests, returns a MAC address component in decimal notation while it should return it in hexadecimal. This means that you get inconsistent MAC addresses once you have 10 nodes or more. Worse: when you have 100 or more nodes the MAC address will look like52:54:00:12:01:100
which is invalid.Things done
This PR fixes the
zeroPad
function to return a proper hexadecimal component which means we can now have up to 254 nodes.The implementation needed the
toHex
andtoBase
functions which have been added to thelib
and come with unit tests.Finally the
dhcpSimple
NixOS test from thenetworking
test suite has been modified to give out fixed IP addresses (instead of a range) based on the MAC address.sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)