175 lines
9.1 KiB
Diff
175 lines
9.1 KiB
Diff
|
From f41cdf561c04d6ec58609f0b11b3a813fa0f6143 Mon Sep 17 00:00:00 2001
|
||
|
From: Inessa Vasilevskaya <ivasilev@redhat.com>
|
||
|
Date: Mon, 29 Aug 2022 10:57:32 +0200
|
||
|
Subject: [PATCH 43/63] Apply changes after rebase and do refactor
|
||
|
|
||
|
Changes done to repos/system_upgrade/el7toel8/actors
|
||
|
have been manually applied to repos/system_upgrade/common/actors
|
||
|
Refactoring is mostly about renaming variable to
|
||
|
LEAPP_DEVEL_INITRAM_NETWORK and moving some changes out of dracut
|
||
|
into the UpgradeTasks.
|
||
|
---
|
||
|
.../libraries/addupgradebootentry.py | 4 ++--
|
||
|
.../common/actors/checknfs/actor.py | 2 +-
|
||
|
.../actors/checknfs/tests/test_checknfs.py | 4 ++--
|
||
|
.../dracut/85sys-upgrade-redhat/do-upgrade.sh | 15 +++++++++++++++
|
||
|
.../libraries/modscan.py | 16 ++++++++++++++++
|
||
|
.../files/generate-initram.sh | 13 -------------
|
||
|
6 files changed, 36 insertions(+), 18 deletions(-)
|
||
|
|
||
|
diff --git a/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py b/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py
|
||
|
index ca9802bb..beddafec 100644
|
||
|
--- a/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py
|
||
|
+++ b/repos/system_upgrade/common/actors/addupgradebootentry/libraries/addupgradebootentry.py
|
||
|
@@ -9,8 +9,8 @@ from leapp.models import BootContent, KernelCmdlineArg, TargetKernelCmdlineArgTa
|
||
|
|
||
|
def add_boot_entry(configs=None):
|
||
|
debug = 'debug' if os.getenv('LEAPP_DEBUG', '0') == '1' else ''
|
||
|
- enable_network = os.getenv('LEAPP_INITRAM_NETWORK') in ('network-manager', 'scripts')
|
||
|
- ip_arg = ' ip=on' if enable_network else ''
|
||
|
+ enable_network = os.getenv('LEAPP_DEVEL_INITRAM_NETWORK') in ('network-manager', 'scripts')
|
||
|
+ ip_arg = ' ip=dhcp rd.neednet=1' if enable_network else ''
|
||
|
kernel_dst_path, initram_dst_path = get_boot_file_paths()
|
||
|
_remove_old_upgrade_boot_entry(kernel_dst_path, configs=configs)
|
||
|
try:
|
||
|
diff --git a/repos/system_upgrade/common/actors/checknfs/actor.py b/repos/system_upgrade/common/actors/checknfs/actor.py
|
||
|
index 370ae6b3..40ca834e 100644
|
||
|
--- a/repos/system_upgrade/common/actors/checknfs/actor.py
|
||
|
+++ b/repos/system_upgrade/common/actors/checknfs/actor.py
|
||
|
@@ -20,7 +20,7 @@ class CheckNfs(Actor):
|
||
|
|
||
|
def process(self):
|
||
|
# if network in initramfs is enabled NFS inhibitors are redundant
|
||
|
- if get_env('LEAPP_INITRAM_NETWORK', None):
|
||
|
+ if get_env('LEAPP_DEVEL_INITRAM_NETWORK', None):
|
||
|
return
|
||
|
details = "NFS is currently not supported by the inplace upgrade.\n" \
|
||
|
"We have found NFS usage at the following locations:\n"
|
||
|
diff --git a/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py b/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
|
||
|
index a8d18ed1..907dca40 100644
|
||
|
--- a/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
|
||
|
+++ b/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
|
||
|
@@ -86,7 +86,7 @@ def test_actor_without_mount_share(current_actor_context, monkeypatch):
|
||
|
|
||
|
def test_actor_skipped_if_initram_network_enabled(current_actor_context, monkeypatch):
|
||
|
"""Check that previous inhibitors are not stopping the upgrade in case env var is set"""
|
||
|
- monkeypatch.setattr(config, 'get_env', lambda x, y: 'network-manager' if x == 'LEAPP_INITRAM_NETWORK' else y)
|
||
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: 'network-manager' if x == 'LEAPP_DEVEL_INITRAM_NETWORK' else y)
|
||
|
with_mount_share = [MountEntry(name="nfs", mount="/mnt/data", tp='nfs',
|
||
|
options="rw,nosuid,nodev,relatime,user_id=1000,group_id=1000")]
|
||
|
with_systemdmount_entry = [SystemdMountEntry(node="nfs", path="n/a", model="n/a",
|
||
|
@@ -105,7 +105,7 @@ def test_actor_skipped_if_initram_network_enabled(current_actor_context, monkeyp
|
||
|
|
||
|
def test_actor_not_skipped_if_initram_network_empty(current_actor_context, monkeypatch):
|
||
|
"""Check that previous inhibitors are not stopping the upgrade in case env var is set"""
|
||
|
- monkeypatch.setattr(config, 'get_env', lambda x, y: '' if x == 'LEAPP_INITRAM_NETWORK' else y)
|
||
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: '' if x == 'LEAPP_DEVEL_INITRAM_NETWORK' else y)
|
||
|
with_mount_share = [MountEntry(name="nfs", mount="/mnt/data", tp='nfs',
|
||
|
options="rw,nosuid,nodev,relatime,user_id=1000,group_id=1000")]
|
||
|
with_systemdmount_entry = [SystemdMountEntry(node="nfs", path="n/a", model="n/a",
|
||
|
diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh
|
||
|
index ff491316..49c26bc8 100755
|
||
|
--- a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh
|
||
|
+++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh
|
||
|
@@ -194,6 +194,19 @@ ibdmp() {
|
||
|
done
|
||
|
}
|
||
|
|
||
|
+bring_up_network() {
|
||
|
+ if [ -f /etc/leapp-initram-network-manager ]; then
|
||
|
+ # NOTE(ivasilev) Reverting the change to see if it caused the crash
|
||
|
+ . /lib/dracut/hooks/cmdline/99-nm-config.sh
|
||
|
+ . /lib/dracut/hooks/initqueue/settled/99-nm-run.sh
|
||
|
+ fi
|
||
|
+ if [ -f /etc/leapp-initram-network-scripts ]; then
|
||
|
+ for interface in /sys/class/net/*;
|
||
|
+ do
|
||
|
+ ifup ${interface##*/};
|
||
|
+ done;
|
||
|
+ fi
|
||
|
+}
|
||
|
|
||
|
do_upgrade() {
|
||
|
local args="" rv=0
|
||
|
@@ -202,6 +215,8 @@ do_upgrade() {
|
||
|
#getargbool 0 rd.upgrade.verbose && args="$args --verbose"
|
||
|
getargbool 0 rd.upgrade.debug && args="$args --debug"
|
||
|
|
||
|
+ bring_up_network
|
||
|
+
|
||
|
# Force selinux into permissive mode unless booted with 'enforcing=1'.
|
||
|
# FIXME: THIS IS A BIG STUPID HAMMER AND WE SHOULD ACTUALLY SOLVE THE ROOT
|
||
|
# PROBLEMS RATHER THAN JUST PAPERING OVER THE WHOLE THING. But this is what
|
||
|
diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/libraries/modscan.py b/repos/system_upgrade/common/actors/commonleappdracutmodules/libraries/modscan.py
|
||
|
index 275b2c63..2b8d78a4 100644
|
||
|
--- a/repos/system_upgrade/common/actors/commonleappdracutmodules/libraries/modscan.py
|
||
|
+++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/libraries/modscan.py
|
||
|
@@ -6,6 +6,7 @@ from leapp.libraries.stdlib import api
|
||
|
from leapp.utils.deprecation import suppress_deprecation
|
||
|
|
||
|
from leapp.models import ( # isort:skip
|
||
|
+ CopyFile,
|
||
|
RequiredUpgradeInitramPackages, # deprecated
|
||
|
UpgradeDracutModule, # deprecated
|
||
|
DracutModule,
|
||
|
@@ -42,6 +43,18 @@ _REQUIRED_PACKAGES = [
|
||
|
]
|
||
|
|
||
|
|
||
|
+def _create_initram_networking_tasks():
|
||
|
+ # include networking-related dracut modules
|
||
|
+ modules_map = {'network-manager': ('network-manager', '/etc/leapp-initram-network-manager'),
|
||
|
+ 'scripts': ('network', '/etc/leapp-initram-network-scripts')}
|
||
|
+ initram_network_chosen = os.getenv('LEAPP_DEVEL_INITRAM_NETWORK', None)
|
||
|
+ if initram_network_chosen in modules_map:
|
||
|
+ module, touch_file = modules_map[initram_network_chosen]
|
||
|
+ yield UpgradeInitramfsTasks(include_dracut_modules=[DracutModule(name=module)])
|
||
|
+ # touch expected file
|
||
|
+ yield TargetUserSpaceUpgradeTasks(copy_files=[CopyFile(src='/dev/null', dst=touch_file)])
|
||
|
+
|
||
|
+
|
||
|
# The decorator is not effective for generators, it has to be used one level
|
||
|
# above
|
||
|
# @suppress_deprecation(UpgradeDracutModule)
|
||
|
@@ -68,6 +81,8 @@ def _create_initram_packages():
|
||
|
required_pkgs = _REQUIRED_PACKAGES[:]
|
||
|
if architecture.matches_architecture(architecture.ARCH_X86_64):
|
||
|
required_pkgs.append('biosdevname')
|
||
|
+ if os.getenv('LEAPP_DEVEL_INITRAM_NETWORK', None) == 'network-manager':
|
||
|
+ required_pkgs.append('NetworkManager')
|
||
|
if version.get_target_major_version() == '9':
|
||
|
required_pkgs += ['policycoreutils', 'rng-tools']
|
||
|
return (
|
||
|
@@ -79,3 +94,4 @@ def _create_initram_packages():
|
||
|
def process():
|
||
|
api.produce(*tuple(_create_dracut_modules()))
|
||
|
api.produce(*_create_initram_packages())
|
||
|
+ api.produce(*tuple(_create_initram_networking_tasks()))
|
||
|
diff --git a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh
|
||
|
index 7748aa78..b3478280 100755
|
||
|
--- a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh
|
||
|
+++ b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh
|
||
|
@@ -67,19 +67,6 @@ build() {
|
||
|
DRACUT_MODULES_ADD=$(echo "--add $LEAPP_ADD_DRACUT_MODULES" | sed 's/,/ --add /g')
|
||
|
fi
|
||
|
|
||
|
- case $LEAPP_INITRAM_NETWORK in
|
||
|
- network-manager)
|
||
|
- DRACUT_MODULES_ADD="$DRACUT_MODULES_ADD --add network-manager"
|
||
|
- touch /etc/leapp-initram-network-manager
|
||
|
- ;;
|
||
|
- scripts)
|
||
|
- DRACUT_MODULES_ADD="$DRACUT_MODULES_ADD --add network";
|
||
|
- touch /etc/leapp-initram-network-scripts
|
||
|
- ;;
|
||
|
- *)
|
||
|
- ;;
|
||
|
- esac
|
||
|
-
|
||
|
DRACUT_INSTALL="systemd-nspawn"
|
||
|
if [[ -n "$LEAPP_DRACUT_INSTALL_FILES" ]]; then
|
||
|
DRACUT_INSTALL="$DRACUT_INSTALL $LEAPP_DRACUT_INSTALL_FILES"
|
||
|
--
|
||
|
2.39.0
|
||
|
|