-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
nixos/stage-1: fix predictable interface names in initrd #79532
Conversation
@GrahamcOfBorg test predictable-interface-names initrdNetwork initrd-network-ssh |
This makes predictable interfaces names available as soon as possible with udev by adding the default network link units to initrd which are read by udev. Also adds some udev rules that are needed but which would normally loaded from the udev store path which is not included in the initrd.
Depending on the network management backend being used, if the interface configuration in stage 1 is not cleared, there might still be some old addresses or routes from stage 1 present in stage 2 after network configuration has finished.
ab02ac4
to
ea7d024
Compare
From a quick glace, this looks like the right way to do (at least until we have systemd in initrd). Can somebody with a "push luks keys over ssh in initrd" setup test this? I don't currently have such a setup around, but we should make sure it now works as intended. Also, we should add something to the release notes, so people who are using such a setup and implemented their workarounds are aware names have changed and don't lock themselves out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a setup which is fairly similar to nixos/tests/initrd-network-ssh
and tested the first commit on multiple servers, didn't find any regressions :)
@petabyteboy @schmittlauch @erikarvstedt @emilazy could you also give this a very firm look? |
I'll try and take a look at this soon -- for what it's worth, I personally successfully use this module and it's the closest thing I've seen to a Correct™ solution for this issue. |
Marked this as a blocker, we should really try to get this fixed for 20.03. |
I'd personally say that's fine to backport as well, if it comes with release notes (and I'd also have preferred if those were part of the initial PR ;-), but now it is how it is)
|
Sorry for that, hit the PR-button too early :/
You're right, just missed it! |
Btw, please PR larger backports. |
Sorry for the delay, currently preparing a PR to backport 5897899. |
As outlined in NixOS#71447, postCommands should always be run if networking in initrd is enabled. regardless if the configuration actually succeeded. (cherry picked from commit 5897899) The backport of this patch has been requested in NixOS#79532[1]. The diff is slightly off the original commit since some changes from ea7d024 were needed, however this commit shouldn't be backported as it potentially breaks existing setups. [1] NixOS#79532 (comment)
@fpletz does it move building bridges to stage-1 as well? I have .useDHCP=true only for br0 and trying to understand if it'll continue working after switching to 20.03. Thanks. |
Hum, this seems to impose predictable interface names in stage-1 even if the main OS has |
@Nadrieril can you show us a minimal NixOS configuration reproducing this? There's |
Hmm, this happened on two of my servers so it's not just a fluke and probably not hardware-related either. But it's difficult to minimize, I can't just break my servers. |
That's most likely the case: without this PR, NixOS had |
Ohh, you mean the interface set up in initrd would carry on to the booted system? That explains a lot! |
@Nadrieril yes the interface names are kept from stage-1 to stage-2, AFAIU there's no more than a |
So this PR actually fixed a bug we didn't know about - even with I don't think that's a bug we should consider a feature and apply workarounds for ;-) We should however update the release note entry explaining the possibly changed behaviour, so people reading those are made aware. |
Ah, nvm - we already refer to this PR in the release notes, and as this landed in 20.03 already, the amount of people still running into it while upgrading should be somewhat small. |
Well, actually this was one of the main issues before this PR (and one of the biggest challenges I had while trying to upgrade to 19.09). The problem was that |
Am I doing something wrong or does this break setting interface names with systemd link units? |
A common pitfall with using network interfaces in initrd is that you need to set them admin down, because you cannot rename interfaces that are admin up. Is the interface properly set to down? Does enabling this block fix your issue? https://github.com/NixOS/nixpkgs/pull/79532/files#diff-5c6eca5d6ffea3065ed16561bec3ca9dR139 |
systemd-udev-settle is a terrible hack[1] and should never[2] ever[3] used, seriously it's very bad. It was used as a stop-gap solution for issue #39069, but thanks to PR #79532 it can be removed now. [1]: systemd/systemd#7293 (comment) [2]: #73095 [3]: #107341
Motivation for this change
This makes predictable interfaces names available as soon as possible with udev by adding the default network link units to initrd which are read by udev. Also adds some udev rules that are needed but which would normally loaded from the udev store path which is not included in the initrd.
Also ensures that the interfaces are unconfigured before switching to stage 2, switches to klibc's ipconfig due to more features and make
boot.initrd.network.postCommands
run regardless if network setup has succeeded.Fixes #74328 #75314 #71447.
Things done
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)