159 lines
8.6 KiB
Diff
159 lines
8.6 KiB
Diff
From f8c96d8a8d2cf8fc1eeac0349aa48fe83567eecb Mon Sep 17 00:00:00 2001
|
|
From: Inessa Vasilevskaya <ivasilev@redhat.com>
|
|
Date: Mon, 5 Sep 2022 11:56:03 +0200
|
|
Subject: [PATCH 42/63] Skip check nfs actor if env var is set
|
|
|
|
In case LEAPP_INITRAM_NETWORK is set nfs upgrade inhibitors
|
|
can be skipped.
|
|
---
|
|
.../common/actors/checknfs/actor.py | 4 ++
|
|
.../actors/checknfs/tests/test_checknfs.py | 61 ++++++++++++++++---
|
|
2 files changed, 58 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/repos/system_upgrade/common/actors/checknfs/actor.py b/repos/system_upgrade/common/actors/checknfs/actor.py
|
|
index f3424504..370ae6b3 100644
|
|
--- a/repos/system_upgrade/common/actors/checknfs/actor.py
|
|
+++ b/repos/system_upgrade/common/actors/checknfs/actor.py
|
|
@@ -1,5 +1,6 @@
|
|
from leapp import reporting
|
|
from leapp.actors import Actor
|
|
+from leapp.libraries.common.config import get_env
|
|
from leapp.models import StorageInfo
|
|
from leapp.reporting import create_report, Report
|
|
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag
|
|
@@ -18,6 +19,9 @@ class CheckNfs(Actor):
|
|
tags = (ChecksPhaseTag, IPUWorkflowTag,)
|
|
|
|
def process(self):
|
|
+ # if network in initramfs is enabled NFS inhibitors are redundant
|
|
+ if get_env('LEAPP_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 7e52440f..a8d18ed1 100644
|
|
--- a/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
|
|
+++ b/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
|
|
@@ -1,5 +1,6 @@
|
|
import pytest
|
|
|
|
+from leapp.libraries.common import config
|
|
from leapp.models import FstabEntry, MountEntry, StorageInfo, SystemdMountEntry
|
|
from leapp.reporting import Report
|
|
from leapp.snactor.fixture import current_actor_context
|
|
@@ -7,7 +8,8 @@ from leapp.utils.report import is_inhibitor
|
|
|
|
|
|
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
|
|
-def test_actor_with_systemdmount_entry(current_actor_context, nfs_fstype):
|
|
+def test_actor_with_systemdmount_entry(current_actor_context, nfs_fstype, monkeypatch):
|
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
|
with_systemdmount_entry = [SystemdMountEntry(node="nfs", path="n/a", model="n/a",
|
|
wwn="n/a", fs_type=nfs_fstype, label="n/a",
|
|
uuid="n/a")]
|
|
@@ -17,7 +19,8 @@ def test_actor_with_systemdmount_entry(current_actor_context, nfs_fstype):
|
|
assert is_inhibitor(report_fields)
|
|
|
|
|
|
-def test_actor_without_systemdmount_entry(current_actor_context):
|
|
+def test_actor_without_systemdmount_entry(current_actor_context, monkeypatch):
|
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
|
without_systemdmount_entry = [SystemdMountEntry(node="/dev/sda1",
|
|
path="pci-0000:00:17.0-ata-2",
|
|
model="TOSHIBA_THNSNJ512GDNU_A",
|
|
@@ -30,7 +33,8 @@ def test_actor_without_systemdmount_entry(current_actor_context):
|
|
|
|
|
|
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
|
|
-def test_actor_with_fstab_entry(current_actor_context, nfs_fstype):
|
|
+def test_actor_with_fstab_entry(current_actor_context, nfs_fstype, monkeypatch):
|
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
|
with_fstab_entry = [FstabEntry(fs_spec="lithium:/mnt/data", fs_file="/mnt/data",
|
|
fs_vfstype=nfs_fstype,
|
|
fs_mntops="noauto,noatime,rsize=32768,wsize=32768",
|
|
@@ -41,7 +45,8 @@ def test_actor_with_fstab_entry(current_actor_context, nfs_fstype):
|
|
assert is_inhibitor(report_fields)
|
|
|
|
|
|
-def test_actor_without_fstab_entry(current_actor_context):
|
|
+def test_actor_without_fstab_entry(current_actor_context, monkeypatch):
|
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
|
without_fstab_entry = [FstabEntry(fs_spec="/dev/mapper/fedora-home", fs_file="/home",
|
|
fs_vfstype="ext4",
|
|
fs_mntops="defaults,x-systemd.device-timeout=0",
|
|
@@ -51,7 +56,8 @@ def test_actor_without_fstab_entry(current_actor_context):
|
|
assert not current_actor_context.consume(Report)
|
|
|
|
|
|
-def test_actor_with_nfsd(current_actor_context):
|
|
+def test_actor_with_nfsd(current_actor_context, monkeypatch):
|
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
|
with_nfsd = [MountEntry(name="nfsd", mount="/proc/fs/nfsd", tp="nfsd", options="rw,relatime")]
|
|
current_actor_context.feed(StorageInfo(mount=with_nfsd))
|
|
current_actor_context.run()
|
|
@@ -59,7 +65,8 @@ def test_actor_with_nfsd(current_actor_context):
|
|
|
|
|
|
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
|
|
-def test_actor_with_mount_share(current_actor_context, nfs_fstype):
|
|
+def test_actor_with_mount_share(current_actor_context, nfs_fstype, monkeypatch):
|
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
|
with_mount_share = [MountEntry(name="nfs", mount="/mnt/data", tp=nfs_fstype,
|
|
options="rw,nosuid,nodev,relatime,user_id=1000,group_id=1000")]
|
|
current_actor_context.feed(StorageInfo(mount=with_mount_share))
|
|
@@ -68,9 +75,49 @@ def test_actor_with_mount_share(current_actor_context, nfs_fstype):
|
|
assert is_inhibitor(report_fields)
|
|
|
|
|
|
-def test_actor_without_mount_share(current_actor_context):
|
|
+def test_actor_without_mount_share(current_actor_context, monkeypatch):
|
|
+ monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
|
without_mount_share = [MountEntry(name="tmpfs", mount="/run/snapd/ns", tp="tmpfs",
|
|
options="rw,nosuid,nodev,seclabel,mode=755")]
|
|
current_actor_context.feed(StorageInfo(mount=without_mount_share))
|
|
current_actor_context.run()
|
|
assert not current_actor_context.consume(Report)
|
|
+
|
|
+
|
|
+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)
|
|
+ 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",
|
|
+ wwn="n/a", fs_type='nfs', label="n/a",
|
|
+ uuid="n/a")]
|
|
+ with_fstab_entry = [FstabEntry(fs_spec="lithium:/mnt/data", fs_file="/mnt/data",
|
|
+ fs_vfstype='nfs',
|
|
+ fs_mntops="noauto,noatime,rsize=32768,wsize=32768",
|
|
+ fs_freq="0", fs_passno="0")]
|
|
+ current_actor_context.feed(StorageInfo(mount=with_mount_share,
|
|
+ systemdmount=with_systemdmount_entry,
|
|
+ fstab=with_fstab_entry))
|
|
+ current_actor_context.run()
|
|
+ assert not current_actor_context.consume(Report)
|
|
+
|
|
+
|
|
+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)
|
|
+ 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",
|
|
+ wwn="n/a", fs_type='nfs', label="n/a",
|
|
+ uuid="n/a")]
|
|
+ with_fstab_entry = [FstabEntry(fs_spec="lithium:/mnt/data", fs_file="/mnt/data",
|
|
+ fs_vfstype='nfs',
|
|
+ fs_mntops="noauto,noatime,rsize=32768,wsize=32768",
|
|
+ fs_freq="0", fs_passno="0")]
|
|
+ current_actor_context.feed(StorageInfo(mount=with_mount_share,
|
|
+ systemdmount=with_systemdmount_entry,
|
|
+ fstab=with_fstab_entry))
|
|
+ current_actor_context.run()
|
|
+ report_fields = current_actor_context.consume(Report)[0].report
|
|
+ assert is_inhibitor(report_fields)
|
|
--
|
|
2.39.0
|
|
|