diff --git a/netplan_cli/cli/commands/apply.py b/netplan_cli/cli/commands/apply.py index b8feee608..ab05a287e 100644 --- a/netplan_cli/cli/commands/apply.py +++ b/netplan_cli/cli/commands/apply.py @@ -262,8 +262,7 @@ def command_apply(self, run_generate=True, sync=False, exit_on_error=True, state stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - # Reloading of udev rules happens during 'netplan generate' already - # subprocess.check_call(['udevadm', 'control', '--reload-rules']) + subprocess.check_call(['udevadm', 'control', '--reload']) subprocess.check_call(['udevadm', 'trigger', '--attr-match=subsystem=net']) subprocess.check_call(['udevadm', 'settle']) diff --git a/netplan_cli/cli/commands/generate.py b/netplan_cli/cli/commands/generate.py index ba51eb0d7..889411dc2 100644 --- a/netplan_cli/cli/commands/generate.py +++ b/netplan_cli/cli/commands/generate.py @@ -82,6 +82,10 @@ def command_generate(self): argv += ['--mapping', self.mapping] logging.debug('command generate: running %s', argv) res = subprocess.call(argv) + try: + subprocess.check_call(['udevadm', 'control', '--reload']) + except subprocess.CalledProcessError as e: + logging.debug(f'Could not call "udevadm control --reload": {str(e)}') # reload systemd, as we might have changed service units, such as # /run/systemd/system/systemd-networkd-wait-online.service.d/10-netplan.conf # Skip it if --mapping is used as nothing will be generated diff --git a/src/generate.c b/src/generate.c index d3d3c6346..658553752 100644 --- a/src/generate.c +++ b/src/generate.c @@ -54,13 +54,6 @@ static GOptionEntry options[] = { {NULL} }; -static void -reload_udevd(void) -{ - const gchar *argv[] = { "/bin/udevadm", "control", "--reload", NULL }; - g_spawn_sync(NULL, (gchar**)argv, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, NULL, NULL); -}; - /** * Create enablement symlink for systemd-networkd.service. */ @@ -307,13 +300,6 @@ int main(int argc, char** argv) CHECK_CALL(netplan_state_finish_nm_write(np_state, rootdir, &error), ignore_errors); CHECK_CALL(netplan_state_finish_sriov_write(np_state, rootdir, &error), ignore_errors); - /* We may have written .rules & .link files, thus we must - * invalidate udevd cache of its config as by default it only - * invalidates cache at most every 3 seconds. Not sure if this - * should live in `generate' or `apply', but it is confusing - * when udevd ignores just-in-time created rules files. - */ - reload_udevd(); } /* Disable /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf