Skip to content

Commit

Permalink
checknfs: do not check systemd mounts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mhecko authored and pirat89 committed Nov 10, 2023
1 parent 594cdb9 commit bf866cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 47 deletions.
15 changes: 2 additions & 13 deletions repos/system_upgrade/common/actors/checknfs/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -41,14 +41,7 @@ def _is_nfs(a_type):
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)
Expand All @@ -57,10 +50,6 @@ def _is_nfs(a_type):
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([
Expand Down
37 changes: 3 additions & 34 deletions repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit bf866cb

Please sign in to comment.