-
Notifications
You must be signed in to change notification settings - Fork 187
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
generator: Don't reload udev in the generator #304
base: main
Are you sure you want to change the base?
Conversation
I rebuilt the netplan pkg for ArchLinux with this PR applied and it resolved the issue for me. |
Just a note (not a full review, yet): We need to double check if this still works for LP#1669564 (f4b0c54) |
These changes break the new dbus integration tests:
|
I wonder if we could do something similar to #162 Instead of calling udevadm syncronoulsy, we could consider deploying a new "netplan-udev-reload.service" unit, which executes something like From the generator we could then eque this "oneshot" command by calling |
9d631f1
to
1104634
Compare
676bb2d
to
0572baf
Compare
The systemd documentation states that any kind of process communication shouldn't happen inside generators. It can cause problems like the one reported in LP#1999178. Ubuntu seems to not be affected by the same issue yet, but as the problem happens due to a race condition we might run into it in the future as well. This change moves the call to the udevadm command from the generator to the Python code. To keep the behaviour as close to the previous one as possible, the call is made as part of the generate command. We could simply check if the generator is being called as a systemd generator and don't call udevadm, but in the end the binary still is a generator so we shouldn't even have that logic there. The same is true for the calls we make to systemd using systemctl. Even though they are not executed when the binary is called as a generator, they probably shouldn't be there.
0572baf
to
3f4259e
Compare
The udev rules directories are monitored and re-loaded automatically with modern systemd-udevd. No need to manually reload them in the generator, causing side-effects. We can still force-reload them when issuing 'netplan generate' or 'netplan apply' through the CLI, just to be on the safe side. Replaces: canonical#304
The udev rules directories are monitored and re-loaded automatically with modern systemd-udevd. No need to manually reload them in the generator, causing side-effects. We can still force-reload them when issuing 'netplan generate' or 'netplan apply' through the CLI, just to be on the safe side. Replaces: canonical#304
The systemd documentation states that any kind of process communication shouldn't happen inside generators. It can cause problems like the one reported in LP#1999178:
Generators are run very early at boot and cannot rely on any external services. They may not talk to any other process. That includes simple things such as logging to syslog(3), or systemd itself (this means: no systemctl(1))!
Ubuntu IS also affected by the same issue! We are observing long pauses during upgrades from Lunar to Mantic due to a package (usbmuxd) installing a udev rules file referring to a user that will be created late in the upgrade process. Every daemon-reload will stuck for 2 minutes, and it's happening many times. While the workaround for this specific case is easy (create the user earlier), users might run in to situations that's out of our control.
This change moves the call to the udevadm command from the generator to the Python code. To keep the behavior as close to the previous one as possible, the call is made as part of the generate command.
We could simply check if the generator is being called as a systemd generator and don't call udevadm, but in the end the binary still is a generator so we shouldn't even have that logic there.
The same is true for the calls we make to systemd using systemctl. Even though they are not executed when the binary is called as a generator, they probably shouldn't be there.
UPDATE:
I'm also proposing that we stop using generators to generate configuration. There are 2 main reasons for that:
Generators should only be used to generate unit files, .d/*.conf drop-ins for them and symlinks to them, not any other kind of non-unit related configuration.
This PR also includes an experimental systemd service that will call the generate binary before running systemd-networkd, Network Manager and cloud-init. While I'm not completely sure it's correct, it appears to work fine.
I have a PPA for Mantic containing these changes here https://launchpad.net/~danilogondolfo/+archive/ubuntu/netplan.io/+packages
Description
Checklist
make check
successfully.make check-coverage
).