-
-
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/networkd: wait for udev to settle before starting networkd #39340
Conversation
... to avoid race condition between udevd renaming and networkd configuring interfaces (39069)
Upstream systemd-networkd now renames network interfaces itself, which seems like a good idea, no? |
We would need udev rules from here:
and also this pull request, which was reverted: #29768 Back then I made the mistake merging/reverting both features independently. |
it's still
Unfortunately no. The race condition occurs because nixos brings up interfaces in stage 1 without renaming them, we only add the renaming rule in The best solution is to do renaming when the interfaces are first created in stage 1, see #39329.
Actually, no if we do the renaming in stage 1.
Thanks for the references, I had not seen your previous PRs. Yes, switching back to upstream rules and There's a small drawback: the builtin mechanism is controlled by the |
@@ -712,6 +712,9 @@ in | |||
systemd.services.systemd-networkd = { | |||
wantedBy = [ "multi-user.target" ]; | |||
restartTriggers = map (f: f.source) (unitFiles); | |||
# prevent race condition with interface renaming (#39069) | |||
requires = [ "systemd-udev-settle.service" ]; | |||
after = [ "systemd-udev-settle.service" ]; |
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.
Personally I have:
systemd.services.systemd-udev-settle.serviceConfig.ExecStart = ["" "${pkgs.coreutils}/bin/true"];
in my configuration because systemd-udev-settle
timeouts on my machine sometimes.
That's why I would be glad if we could get rid of that service sometimes.
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 agree this is not ideal but the best we can do in stage 2 to prevent the race condition. We can revert this as soon as we do the renaming in stage 1.
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.
Instead of using systemd-udev-settle
, we could add
serviceConfig.ExecStartPre="${systemd.package}/bin/udevadm settle -t 10";
directly to systemd-networkd
to use a shorter timeout than the default 120s. I guess 10s will be enough to get interface renaming done... ( on a real system, but on hydra you never know).
LGTM |
Motivation for this change
Fix #39069: Avoid a race condition between
udevd
renaming andnetworkd
configuring interfaces when usingnetworkd
with predictable interface names.Please backport to 18.03 because a resulting non-deterministic test failure has frequently delayed the
nixos-18.03-small
channel.This is an interim fix to get rid of the race condition and resulting test failures. It does not break existing configs that use the old
ethX
interface names for stage 1 (initrd) networking, so it should be safe to backport to 18.03.(#39329 proposes a better long-term solution: rename interfaces in stage 1 already, so interface names are consistently the same in initrd and fully booted system. But that change will break initrd networking in some existing configs, so we should make it carefully.)
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)