135 lines
7.4 KiB
Diff
135 lines
7.4 KiB
Diff
|
From bf866cb33d9aefb2d6d79fc6ea0e326c6c2a0cf3 Mon Sep 17 00:00:00 2001
|
||
|
From: mhecko <mhecko@redhat.com>
|
||
|
Date: Thu, 14 Sep 2023 13:43:37 +0200
|
||
|
Subject: [PATCH 28/38] checknfs: do not check systemd mounts
|
||
|
|
||
|
Systemd mounts contain only *block* devices. Therefore, the list can
|
||
|
never contain NFS shares at all and the check is redundant. This is
|
||
|
apparent if one reads storagescanner/libraries/storagescanner.py:L251.
|
||
|
This patch, therefore, removes the check for systemd mount alltogether.
|
||
|
---
|
||
|
.../common/actors/checknfs/actor.py | 15 +-------
|
||
|
.../actors/checknfs/tests/test_checknfs.py | 37 ++-----------------
|
||
|
2 files changed, 5 insertions(+), 47 deletions(-)
|
||
|
|
||
|
diff --git a/repos/system_upgrade/common/actors/checknfs/actor.py b/repos/system_upgrade/common/actors/checknfs/actor.py
|
||
|
index 40ca834e..208c5dd9 100644
|
||
|
--- a/repos/system_upgrade/common/actors/checknfs/actor.py
|
||
|
+++ b/repos/system_upgrade/common/actors/checknfs/actor.py
|
||
|
@@ -10,7 +10,7 @@ class CheckNfs(Actor):
|
||
|
"""
|
||
|
Check if NFS filesystem is in use. If yes, inhibit the upgrade process.
|
||
|
|
||
|
- Actor looks for NFS in the following sources: /ets/fstab, mount and systemd-mount.
|
||
|
+ Actor looks for NFS in the following sources: /ets/fstab and mount.
|
||
|
If there is NFS in any of the mentioned sources, actors inhibits the upgrade.
|
||
|
"""
|
||
|
name = "check_nfs"
|
||
|
@@ -41,14 +41,7 @@ class CheckNfs(Actor):
|
||
|
if _is_nfs(mount.tp):
|
||
|
nfs_mounts.append(" - {} {}\n".format(mount.name, mount.mount))
|
||
|
|
||
|
- # Check systemd-mount
|
||
|
- systemd_nfs_mounts = []
|
||
|
- for systemdmount in storage.systemdmount:
|
||
|
- if _is_nfs(systemdmount.fs_type):
|
||
|
- # mountpoint is not available in the model
|
||
|
- systemd_nfs_mounts.append(" - {}\n".format(systemdmount.node))
|
||
|
-
|
||
|
- if any((fstab_nfs_mounts, nfs_mounts, systemd_nfs_mounts)):
|
||
|
+ if any((fstab_nfs_mounts, nfs_mounts)):
|
||
|
if fstab_nfs_mounts:
|
||
|
details += "- NFS shares found in /etc/fstab:\n"
|
||
|
details += ''.join(fstab_nfs_mounts)
|
||
|
@@ -57,10 +50,6 @@ class CheckNfs(Actor):
|
||
|
details += "- NFS shares currently mounted:\n"
|
||
|
details += ''.join(nfs_mounts)
|
||
|
|
||
|
- if systemd_nfs_mounts:
|
||
|
- details += "- NFS mounts configured with systemd-mount:\n"
|
||
|
- details += ''.join(systemd_nfs_mounts)
|
||
|
-
|
||
|
fstab_related_resource = [reporting.RelatedResource('file', '/etc/fstab')] if fstab_nfs_mounts else []
|
||
|
|
||
|
create_report([
|
||
|
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 907dca40..739b3a83 100644
|
||
|
--- a/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
|
||
|
+++ b/repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
|
||
|
@@ -1,37 +1,12 @@
|
||
|
import pytest
|
||
|
|
||
|
from leapp.libraries.common import config
|
||
|
-from leapp.models import FstabEntry, MountEntry, StorageInfo, SystemdMountEntry
|
||
|
+from leapp.models import FstabEntry, MountEntry, StorageInfo
|
||
|
from leapp.reporting import Report
|
||
|
from leapp.snactor.fixture import current_actor_context
|
||
|
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, 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")]
|
||
|
- current_actor_context.feed(StorageInfo(systemdmount=with_systemdmount_entry))
|
||
|
- current_actor_context.run()
|
||
|
- report_fields = current_actor_context.consume(Report)[0].report
|
||
|
- assert is_inhibitor(report_fields)
|
||
|
-
|
||
|
-
|
||
|
-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",
|
||
|
- wwn="0x500080d9108e8753",
|
||
|
- fs_type="ext4", label="n/a",
|
||
|
- uuid="5675d309-eff7-4eb1-9c27-58bc5880ec72")]
|
||
|
- current_actor_context.feed(StorageInfo(systemdmount=without_systemdmount_entry))
|
||
|
- current_actor_context.run()
|
||
|
- assert not current_actor_context.consume(Report)
|
||
|
-
|
||
|
-
|
||
|
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
|
||
|
def test_actor_with_fstab_entry(current_actor_context, nfs_fstype, monkeypatch):
|
||
|
monkeypatch.setattr(config, 'get_env', lambda x, y: y)
|
||
|
@@ -89,15 +64,12 @@ def test_actor_skipped_if_initram_network_enabled(current_actor_context, monkeyp
|
||
|
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",
|
||
|
- 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,
|
||
|
+ systemdmount=[],
|
||
|
fstab=with_fstab_entry))
|
||
|
current_actor_context.run()
|
||
|
assert not current_actor_context.consume(Report)
|
||
|
@@ -108,15 +80,12 @@ def test_actor_not_skipped_if_initram_network_empty(current_actor_context, monke
|
||
|
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",
|
||
|
- 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,
|
||
|
+ systemdmount=[],
|
||
|
fstab=with_fstab_entry))
|
||
|
current_actor_context.run()
|
||
|
report_fields = current_actor_context.consume(Report)[0].report
|
||
|
--
|
||
|
2.41.0
|
||
|
|