cloud-setup: add pre-up event to prevent reaching network-online.target
network-online.target should not be reached before nm-cloud-setup completes configuring the network, which may make user service get started before the network is fully configured. Setting nm-cloud-setup.service as "Before=network-online.target" would maybe have already achieved that. However, also use a pre-up dispatcher script, so that the device activation in NetworkManager is also waiting for nm-cloud-setup to complete. https://bugzilla.redhat.com/show_bug.cgi?id=2151040 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1653
This commit is contained in:
@@ -5419,12 +5419,14 @@ src/nm-cloud-setup/nm-cloud-setup.service: $(srcdir)/src/nm-cloud-setup/nm-cloud
|
|||||||
$(AM_V_GEN) $(data_edit) $< >$@
|
$(AM_V_GEN) $(data_edit) $< >$@
|
||||||
|
|
||||||
install-data-hook-cloud-setup: install-data-hook-dispatcher
|
install-data-hook-cloud-setup: install-data-hook-dispatcher
|
||||||
$(INSTALL_SCRIPT) "$(srcdir)/src/nm-cloud-setup/90-nm-cloud-setup.sh" "$(DESTDIR)$(nmlibdir)/dispatcher.d/no-wait.d/"
|
$(INSTALL_SCRIPT) "$(srcdir)/src/nm-cloud-setup/90-nm-cloud-setup.sh" "$(DESTDIR)$(nmlibdir)/dispatcher.d/pre-up.d/"
|
||||||
|
ln -fs ../pre-up.d/90-nm-cloud-setup.sh "$(DESTDIR)$(nmlibdir)/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh"
|
||||||
ln -fs no-wait.d/90-nm-cloud-setup.sh "$(DESTDIR)$(nmlibdir)/dispatcher.d/90-nm-cloud-setup.sh"
|
ln -fs no-wait.d/90-nm-cloud-setup.sh "$(DESTDIR)$(nmlibdir)/dispatcher.d/90-nm-cloud-setup.sh"
|
||||||
|
|
||||||
install_data_hook += install-data-hook-cloud-setup
|
install_data_hook += install-data-hook-cloud-setup
|
||||||
|
|
||||||
uninstall-hook-cloud-setup:
|
uninstall-hook-cloud-setup:
|
||||||
|
rm -f "$(DESTDIR)$(nmlibdir)/dispatcher.d/pre-up.d/90-nm-cloud-setup.sh"
|
||||||
rm -f "$(DESTDIR)$(nmlibdir)/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh"
|
rm -f "$(DESTDIR)$(nmlibdir)/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh"
|
||||||
rm -f "$(DESTDIR)$(nmlibdir)/dispatcher.d/90-nm-cloud-setup.sh"
|
rm -f "$(DESTDIR)$(nmlibdir)/dispatcher.d/90-nm-cloud-setup.sh"
|
||||||
|
|
||||||
|
@@ -1243,6 +1243,7 @@ fi
|
|||||||
%{_unitdir}/nm-cloud-setup.timer
|
%{_unitdir}/nm-cloud-setup.timer
|
||||||
%{nmlibdir}/dispatcher.d/90-nm-cloud-setup.sh
|
%{nmlibdir}/dispatcher.d/90-nm-cloud-setup.sh
|
||||||
%{nmlibdir}/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh
|
%{nmlibdir}/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh
|
||||||
|
%{nmlibdir}/dispatcher.d/pre-up.d/90-nm-cloud-setup.sh
|
||||||
%{_mandir}/man8/nm-cloud-setup.8*
|
%{_mandir}/man8/nm-cloud-setup.8*
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
@@ -1,9 +1,17 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
case "$2" in
|
case "$2" in
|
||||||
up|dhcp4-change)
|
pre-up)
|
||||||
if systemctl -q is-enabled nm-cloud-setup.service ; then
|
NO_BLOCK=
|
||||||
exec systemctl --no-block restart nm-cloud-setup.service
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
dhcp4-change)
|
||||||
|
NO_BLOCK=--no-block
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if systemctl -q is-enabled nm-cloud-setup.service ; then
|
||||||
|
exec systemctl $NO_BLOCK restart nm-cloud-setup.service
|
||||||
|
fi
|
||||||
|
@@ -16,7 +16,7 @@ if install_systemdunitdir
|
|||||||
|
|
||||||
install_data(
|
install_data(
|
||||||
'90-nm-cloud-setup.sh',
|
'90-nm-cloud-setup.sh',
|
||||||
install_dir: join_paths(nm_pkglibdir, 'dispatcher.d', 'no-wait.d'),
|
install_dir: join_paths(nm_pkglibdir, 'dispatcher.d', 'pre-up.d'),
|
||||||
)
|
)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Automatically configure NetworkManager in cloud
|
Description=Automatically configure NetworkManager in cloud
|
||||||
Documentation=man:nm-cloud-setup(8)
|
Documentation=man:nm-cloud-setup(8)
|
||||||
|
Before=network-online.target
|
||||||
After=NetworkManager.service
|
After=NetworkManager.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
@@ -55,6 +55,7 @@ if [ "$enable_ifcfg_rh" = 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$enable_nm_cloud_setup" = 1 -a "$install_systemdunitdir" = 1 ]; then
|
if [ "$enable_nm_cloud_setup" = 1 -a "$install_systemdunitdir" = 1 ]; then
|
||||||
|
ln -sfn '../pre-up.d/90-nm-cloud-setup.sh' "${DESTDIR}${nm_pkglibdir}/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh"
|
||||||
ln -sfn 'no-wait.d/90-nm-cloud-setup.sh' "${DESTDIR}${nm_pkglibdir}/dispatcher.d/90-nm-cloud-setup.sh"
|
ln -sfn 'no-wait.d/90-nm-cloud-setup.sh' "${DESTDIR}${nm_pkglibdir}/dispatcher.d/90-nm-cloud-setup.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user