Backport PR #1611 to fix network manager when console is not usable

This commit is contained in:
Olivier Lemasle 2021-10-26 21:06:17 +02:00
parent 56d90eedfb
commit 59c2556942
2 changed files with 112 additions and 1 deletions

View File

@ -0,0 +1,106 @@
From 5ddcd63cc23dc8cf5afe00655bf05319a851a60f Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Mon, 27 Sep 2021 13:08:34 +0200
Subject: [PATCH 1/2] fix(network-manager): show output on console only with
rd.debug enabled
The module should show the output on console only when initrd debugging is
enabled.
---
modules.d/35network-manager/nm-config.sh | 9 +++++++++
modules.d/35network-manager/nm-initrd.service | 4 +++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/modules.d/35network-manager/nm-config.sh b/modules.d/35network-manager/nm-config.sh
index 74b6db54a4..85f89cb03d 100755
--- a/modules.d/35network-manager/nm-config.sh
+++ b/modules.d/35network-manager/nm-config.sh
@@ -16,6 +16,15 @@ if getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then
echo '[logging]'
echo 'level=TRACE'
) > /run/NetworkManager/conf.d/initrd-logging.conf
+
+ if [ -n "$DRACUT_SYSTEMD" ]; then
+ mkdir -p /run/systemd/system/nm-initrd.service.d
+ cat << EOF > /run/systemd/system/nm-initrd.service.d/tty-output.conf
+[Service]
+StandardOutput=tty
+EOF
+ systemctl --no-block daemon-reload
+ fi
fi
nm_generate_connections
diff --git a/modules.d/35network-manager/nm-initrd.service b/modules.d/35network-manager/nm-initrd.service
index b9806de084..ad14e91ad1 100644
--- a/modules.d/35network-manager/nm-initrd.service
+++ b/modules.d/35network-manager/nm-initrd.service
@@ -17,7 +17,9 @@ BusName=org.freedesktop.NetworkManager
ExecReload=/usr/bin/busctl call org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager Reload u 0
ExecStart=/usr/sbin/NetworkManager --debug
KillMode=process
-StandardOutput=tty
+# The following gets changed to StandardOutput=tty by nm-config.sh
+# when debug is enabled.
+StandardOutput=null
Environment=NM_CONFIG_ENABLE_TAG=initrd
Restart=on-failure
ProtectSystem=true
From aa55f515b51a67f5ac9298b7bcb11158cdf885ff Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Mon, 27 Sep 2021 13:25:55 +0200
Subject: [PATCH 2/2] fix(network-manager): disable tty output if the console
is not usable
The network-manager module also writes logs to the console, so that it's easier
to debug network-related boot issues. If systemd can't open the console, the
service fails and network doesn't get configured.
Add a check to disable tty output when the console is not present or not
usable.
https://github.com/coreos/fedora-coreos-tracker/issues/943
---
modules.d/35network-manager/nm-config.sh | 11 ++++++++---
modules.d/35network-manager/nm-initrd.service | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules.d/35network-manager/nm-config.sh b/modules.d/35network-manager/nm-config.sh
index 85f89cb03d..2b13d0a792 100755
--- a/modules.d/35network-manager/nm-config.sh
+++ b/modules.d/35network-manager/nm-config.sh
@@ -18,12 +18,17 @@ if getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then
) > /run/NetworkManager/conf.d/initrd-logging.conf
if [ -n "$DRACUT_SYSTEMD" ]; then
- mkdir -p /run/systemd/system/nm-initrd.service.d
- cat << EOF > /run/systemd/system/nm-initrd.service.d/tty-output.conf
+ # Enable tty output if a usable console is found
+ # See https://github.com/coreos/fedora-coreos-tracker/issues/943
+ # shellcheck disable=SC2217
+ if [ -w /dev/console ] && (echo < /dev/console) > /dev/null 2> /dev/null; then
+ mkdir -p /run/systemd/system/nm-initrd.service.d
+ cat << EOF > /run/systemd/system/nm-initrd.service.d/tty-output.conf
[Service]
StandardOutput=tty
EOF
- systemctl --no-block daemon-reload
+ systemctl --no-block daemon-reload
+ fi
fi
fi
diff --git a/modules.d/35network-manager/nm-initrd.service b/modules.d/35network-manager/nm-initrd.service
index ad14e91ad1..3e24f52a0a 100644
--- a/modules.d/35network-manager/nm-initrd.service
+++ b/modules.d/35network-manager/nm-initrd.service
@@ -18,7 +18,7 @@ ExecReload=/usr/bin/busctl call org.freedesktop.NetworkManager /org/freedesktop/
ExecStart=/usr/sbin/NetworkManager --debug
KillMode=process
# The following gets changed to StandardOutput=tty by nm-config.sh
-# when debug is enabled.
+# when debug is enabled and a usable console is found.
StandardOutput=null
Environment=NM_CONFIG_ENABLE_TAG=initrd
Restart=on-failure

View File

@ -5,7 +5,7 @@
# strip the automatically generated dep here and instead co-own the # strip the automatically generated dep here and instead co-own the
# directory. # directory.
%global __requires_exclude pkg-config %global __requires_exclude pkg-config
%define dist_free_release 5 %define dist_free_release 6
Name: dracut Name: dracut
Version: 055 Version: 055
@ -50,6 +50,8 @@ Patch4: 0001-fix-90kernel-modules-add-Type-C-USB-drivers-for-gene.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2010058 # https://bugzilla.redhat.com/show_bug.cgi?id=2010058
# https://github.com/dracutdevs/dracut/pull/1584 # https://github.com/dracutdevs/dracut/pull/1584
Patch5: 0001-fix-kernel-modules-add-blk_mq_alloc_disk-and-blk_cle.patch Patch5: 0001-fix-kernel-modules-add-blk_mq_alloc_disk-and-blk_cle.patch
# Network manager: disable tty output if the console is not usable
Patch6: https://github.com/dracutdevs/dracut/pull/1611.patch#/0001-fix-network-manager-disable-tty-if-no-console.patch
BuildRequires: bash BuildRequires: bash
BuildRequires: git-core BuildRequires: git-core
@ -503,6 +505,9 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%changelog %changelog
* Tue Oct 26 2021 Olivier Lemasle <o.lemasle@gmail.com> - 055-6
- Backport PR #1611 to fix network manager when console is not usable
* Mon Oct 18 2021 Adam Williamson <awilliam@redhat.com> - 055-5 * Mon Oct 18 2021 Adam Williamson <awilliam@redhat.com> - 055-5
- Backport PR #1584 to fix missing block drivers, boot in EC2 (#2010058) - Backport PR #1584 to fix missing block drivers, boot in EC2 (#2010058)