Backport a few upstream fixes

- Backport: fix(dracut-logger.sh): double dash trigger unknown logger warnings during run
- Backport: fix(network-manager): nm-run.service: don't kill forked processes
- Backport: fix(network-manager): only run NetworkManager if rd.neednet=1
- Backport: fix(network-manager): use /run/NetworkManager/initrd/neednet in initqueue
This commit is contained in:
Dusty Mabe 2021-04-19 10:52:39 -04:00
parent eeb15e69ee
commit fbb2532e93
5 changed files with 203 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 4fbccde50456f513d388cdfd858018cd889890dc Mon Sep 17 00:00:00 2001
From: Dusty Mabe <dusty@dustymabe.com>
Date: Wed, 14 Apr 2021 16:23:29 -0400
Subject: [PATCH] fix(dracut-logger.sh): double dash trigger unknown logger
warnings during run
There are a bunch of `logger: unknown facility name: --user` errors
during a run. This is because logger is getting passed something like:
```
logger -p --user.info
```
Where it should be something like:
```
logger -p user.info
```
---
dracut-logger.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dracut-logger.sh b/dracut-logger.sh
index c36525d0..07389285 100755
--- a/dracut-logger.sh
+++ b/dracut-logger.sh
@@ -241,7 +241,7 @@ _lvl2char() {
# @retval 0 if @a lvl is correct.
# @result Echoes logger priority.
_lvl2syspri() {
- printf "%s" -- "$syslogfacility."
+ printf -- "%s" "$syslogfacility."
case "$1" in
1) echo crit;;
2) echo error;;
--
2.30.2

View File

@ -0,0 +1,46 @@
From 1f21fac646daa46cbe184ef8ff7705842f06ba15 Mon Sep 17 00:00:00 2001
From: Dusty Mabe <dusty@dustymabe.com>
Date: Wed, 14 Apr 2021 10:46:12 -0400
Subject: [PATCH] fix(network-manager): nm-run.service: don't kill forked
processes
If teaming is set up via NetworkManager we don't want systemd to take
down the userspace teamd process when NetworkManager quits. `KillMode=process`
will allow it to leave those processes behind.
This is fallout from the change to run NetworkManager via systemd (c17c5b7).
With `KillMode=process` we get something like:
```
sh-5.1# journalctl -u nm-run -o cat | tail
<info> [1618411262.7030] quitting now that startup is complete
<info> [1618411262.7030] device (team0): carrier: link connected
<info> [1618411262.7033] device (team0): team port ens2 was released
<info> [1618411262.7033] device (team0): team port ens3 was released
<info> [1618411262.7033] manager: NetworkManager state is now CONNECTED_SITE
<info> [1618411262.7034] exiting (success)
nm-run.service: Deactivated successfully.
nm-run.service: Unit process 476 (teamd) remains running after unit stopped.
Finished nm-run.service.
```
---
modules.d/35network-manager/nm-run.service | 2 ++
1 file changed, 2 insertions(+)
diff --git a/modules.d/35network-manager/nm-run.service b/modules.d/35network-manager/nm-run.service
index f3493c41..b667ce37 100644
--- a/modules.d/35network-manager/nm-run.service
+++ b/modules.d/35network-manager/nm-run.service
@@ -23,6 +23,8 @@ ConditionPathExistsGlob=|/etc/sysconfig/network-scripts/ifcfg-*
#run the script and wait before it finishes
Type=oneshot
ExecStart=/usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
+#don't kill forked off processes (for example: teamd for teaming)
+KillMode=process
[Install]
WantedBy=initrd.target
--
2.30.2

View File

@ -0,0 +1,47 @@
From ac0e8f7dcc81432311906c3fca0d4211f6a2f68c Mon Sep 17 00:00:00 2001
From: Dusty Mabe <dusty@dustymabe.com>
Date: Tue, 13 Apr 2021 11:36:21 -0400
Subject: [PATCH 1/2] fix(network-manager): only run NetworkManager if
rd.neednet=1
Don't run the new systemd unit (nm-run.service) if rd.neednet=1
isn't set. nm-initrd-generator will generate configuration even
without rd.neednet=1 so determining if we should start based on
just if connection profiles exist isn't enough. We need some other
indicator. In this case we lay down a /run/NetworkManager/initrd/neednet
if rd.neednet=1, which is used by nm-run.service to determine the
need to run.
---
modules.d/35network-manager/nm-lib.sh | 1 +
modules.d/35network-manager/nm-run.service | 3 +++
2 files changed, 4 insertions(+)
diff --git a/modules.d/35network-manager/nm-lib.sh b/modules.d/35network-manager/nm-lib.sh
index fe053cf..d756022 100644
--- a/modules.d/35network-manager/nm-lib.sh
+++ b/modules.d/35network-manager/nm-lib.sh
@@ -14,6 +14,7 @@ nm_generate_connections()
/etc/sysconfig/network-scripts/ifcfg-*; do
[ -f "$i" ] || continue
echo '[ -f /tmp/nm.done ]' >$hookdir/initqueue/finished/nm.sh
+ : > /run/NetworkManager/initrd/neednet # activate nm-run.service
break
done
fi
diff --git a/modules.d/35network-manager/nm-run.service b/modules.d/35network-manager/nm-run.service
index b667ce3..f041ade 100644
--- a/modules.d/35network-manager/nm-run.service
+++ b/modules.d/35network-manager/nm-run.service
@@ -15,6 +15,9 @@ Before=network.target network-online.target
#run before we try to mount anything from the dracut hooks
Before=dracut-initqueue.service
+#do not run if networking not needed
+ConditionPathExists=/run/NetworkManager/initrd/neednet
+
#do not run, if there is no configuration
ConditionPathExistsGlob=|/usr/lib/NetworkManager/system-connections/*
ConditionPathExistsGlob=|/run/NetworkManager/system-connections/*
--
2.30.2

View File

@ -0,0 +1,55 @@
From 6a37c6f6302f950df608db3fd45acf9342ee3de2 Mon Sep 17 00:00:00 2001
From: Dusty Mabe <dusty@dustymabe.com>
Date: Tue, 13 Apr 2021 11:45:35 -0400
Subject: [PATCH 2/2] fix(network-manager): use
/run/NetworkManager/initrd/neednet in initqueue
We don't want to start NetworkManager if networking is not needed.
Right now nm-config.sh lays down /usr/lib/dracut/hooks/initqueue/finished/nm.sh
which will cause the initqueue to run. If nothing exists in
/usr/lib/dracut/hooks/initqueue/finished/ then it will short circuit and
the initqueue won't run anything. But what if something else needed
something to run in the initqueue? nm-run.sh would still get started,
even though /usr/lib/dracut/hooks/initqueue/finished/nm.sh didn't exist.
In this case let's just trigger off of /run/NetworkManager/initrd/neednet
like we are doing in the systemd unit (nm-run.service).
---
modules.d/35network-manager/nm-run.sh | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/modules.d/35network-manager/nm-run.sh b/modules.d/35network-manager/nm-run.sh
index d48028df..359bc9ee 100755
--- a/modules.d/35network-manager/nm-run.sh
+++ b/modules.d/35network-manager/nm-run.sh
@@ -6,15 +6,19 @@ if [ -e /tmp/nm.done ]; then
return
fi
-[ -z "$DRACUT_SYSTEMD" ] && \
-for i in /usr/lib/NetworkManager/system-connections/* \
- /run/NetworkManager/system-connections/* \
- /etc/NetworkManager/system-connections/* \
- /etc/sysconfig/network-scripts/ifcfg-*; do
- [ -f "$i" ] || continue
- /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
- break
-done
+if [ -z "$DRACUT_SYSTEMD" ]; then
+ # Only start NM if networking is needed
+ if [ -e /run/NetworkManager/initrd/neednet ]; then
+ for i in /usr/lib/NetworkManager/system-connections/* \
+ /run/NetworkManager/system-connections/* \
+ /etc/NetworkManager/system-connections/* \
+ /etc/sysconfig/network-scripts/ifcfg-*; do
+ [ -f "$i" ] || continue
+ /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
+ break
+ done
+ fi
+fi
if [ -s /run/NetworkManager/initrd/hostname ]; then
cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname
--
2.30.2

View File

@ -5,7 +5,7 @@
# strip the automatically generated dep here and instead co-own the
# directory.
%global __requires_exclude pkg-config
%define dist_free_release 3
%define dist_free_release 4
Name: dracut
Version: 053
@ -39,6 +39,16 @@ Patch0: 0001-fix-network-manager-no-default-deps-for-nm-run.servi.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1936781#c6
# Should fix loss of critical system files with kdump enabled
Patch1: 0001-Partially-revert-41cfdfc-to-fix-RHBZ-1936781-per-ryn.patch
# Fix logger error when building initramfs
# https://github.com/dracutdevs/dracut/pull/1351
Patch2: 0001-fix-dracut-logger.sh-double-dash-trigger-unknown-log.patch
# Fix issue where teaming would get brought down by systemd
# https://github.com/dracutdevs/dracut/pull/1349
Patch3: 0001-fix-network-manager-nm-run.service-don-t-kill-forked.patch
# Fix issue where NM was getting brought up unconditionally
# https://github.com/dracutdevs/dracut/pull/1347
Patch4: 0001-fix-network-manager-only-run-NetworkManager-if-rd.ne.patch
Patch5: 0002-fix-network-manager-use-run-NetworkManager-initrd-ne.patch
BuildRequires: bash
BuildRequires: git-core
@ -488,6 +498,12 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%changelog
* Mon Apr 19 2021 Dusty Mabe <dusty@dustymabe.com> - 053-4
- Backport: fix(dracut-logger.sh): double dash trigger unknown logger warnings during run
- Backport: fix(network-manager): nm-run.service: don't kill forked processes
- Backport: fix(network-manager): only run NetworkManager if rd.neednet=1
- Backport: fix(network-manager): use /run/NetworkManager/initrd/neednet in initqueue
* Mon Apr 19 2021 Adam Williamson <awilliam@redhat.com> - 053-3
- Fix removal of key system files when kdump enabled (thanks kasong) (#1936781)