Skip to content

Commit ec54476

Browse files
mheckopirat89
authored andcommitted
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.
1 parent d1f28cb commit ec54476

File tree

2 files changed

+5
-47
lines changed

2 files changed

+5
-47
lines changed

repos/system_upgrade/common/actors/checknfs/actor.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CheckNfs(Actor):
1010
"""
1111
Check if NFS filesystem is in use. If yes, inhibit the upgrade process.
1212
13-
Actor looks for NFS in the following sources: /ets/fstab, mount and systemd-mount.
13+
Actor looks for NFS in the following sources: /ets/fstab and mount.
1414
If there is NFS in any of the mentioned sources, actors inhibits the upgrade.
1515
"""
1616
name = "check_nfs"
@@ -41,14 +41,7 @@ def _is_nfs(a_type):
4141
if _is_nfs(mount.tp):
4242
nfs_mounts.append(" - {} {}\n".format(mount.name, mount.mount))
4343

44-
# Check systemd-mount
45-
systemd_nfs_mounts = []
46-
for systemdmount in storage.systemdmount:
47-
if _is_nfs(systemdmount.fs_type):
48-
# mountpoint is not available in the model
49-
systemd_nfs_mounts.append(" - {}\n".format(systemdmount.node))
50-
51-
if any((fstab_nfs_mounts, nfs_mounts, systemd_nfs_mounts)):
44+
if any((fstab_nfs_mounts, nfs_mounts)):
5245
if fstab_nfs_mounts:
5346
details += "- NFS shares found in /etc/fstab:\n"
5447
details += ''.join(fstab_nfs_mounts)
@@ -57,10 +50,6 @@ def _is_nfs(a_type):
5750
details += "- NFS shares currently mounted:\n"
5851
details += ''.join(nfs_mounts)
5952

60-
if systemd_nfs_mounts:
61-
details += "- NFS mounts configured with systemd-mount:\n"
62-
details += ''.join(systemd_nfs_mounts)
63-
6453
fstab_related_resource = [reporting.RelatedResource('file', '/etc/fstab')] if fstab_nfs_mounts else []
6554

6655
create_report([

repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,12 @@
11
import pytest
22

33
from leapp.libraries.common import config
4-
from leapp.models import FstabEntry, MountEntry, StorageInfo, SystemdMountEntry
4+
from leapp.models import FstabEntry, MountEntry, StorageInfo
55
from leapp.reporting import Report
66
from leapp.snactor.fixture import current_actor_context
77
from leapp.utils.report import is_inhibitor
88

99

10-
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
11-
def test_actor_with_systemdmount_entry(current_actor_context, nfs_fstype, monkeypatch):
12-
monkeypatch.setattr(config, 'get_env', lambda x, y: y)
13-
with_systemdmount_entry = [SystemdMountEntry(node="nfs", path="n/a", model="n/a",
14-
wwn="n/a", fs_type=nfs_fstype, label="n/a",
15-
uuid="n/a")]
16-
current_actor_context.feed(StorageInfo(systemdmount=with_systemdmount_entry))
17-
current_actor_context.run()
18-
report_fields = current_actor_context.consume(Report)[0].report
19-
assert is_inhibitor(report_fields)
20-
21-
22-
def test_actor_without_systemdmount_entry(current_actor_context, monkeypatch):
23-
monkeypatch.setattr(config, 'get_env', lambda x, y: y)
24-
without_systemdmount_entry = [SystemdMountEntry(node="/dev/sda1",
25-
path="pci-0000:00:17.0-ata-2",
26-
model="TOSHIBA_THNSNJ512GDNU_A",
27-
wwn="0x500080d9108e8753",
28-
fs_type="ext4", label="n/a",
29-
uuid="5675d309-eff7-4eb1-9c27-58bc5880ec72")]
30-
current_actor_context.feed(StorageInfo(systemdmount=without_systemdmount_entry))
31-
current_actor_context.run()
32-
assert not current_actor_context.consume(Report)
33-
34-
3510
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
3611
def test_actor_with_fstab_entry(current_actor_context, nfs_fstype, monkeypatch):
3712
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
8964
monkeypatch.setattr(config, 'get_env', lambda x, y: 'network-manager' if x == 'LEAPP_DEVEL_INITRAM_NETWORK' else y)
9065
with_mount_share = [MountEntry(name="nfs", mount="/mnt/data", tp='nfs',
9166
options="rw,nosuid,nodev,relatime,user_id=1000,group_id=1000")]
92-
with_systemdmount_entry = [SystemdMountEntry(node="nfs", path="n/a", model="n/a",
93-
wwn="n/a", fs_type='nfs', label="n/a",
94-
uuid="n/a")]
9567
with_fstab_entry = [FstabEntry(fs_spec="lithium:/mnt/data", fs_file="/mnt/data",
9668
fs_vfstype='nfs',
9769
fs_mntops="noauto,noatime,rsize=32768,wsize=32768",
9870
fs_freq="0", fs_passno="0")]
9971
current_actor_context.feed(StorageInfo(mount=with_mount_share,
100-
systemdmount=with_systemdmount_entry,
72+
systemdmount=[],
10173
fstab=with_fstab_entry))
10274
current_actor_context.run()
10375
assert not current_actor_context.consume(Report)
@@ -108,15 +80,12 @@ def test_actor_not_skipped_if_initram_network_empty(current_actor_context, monke
10880
monkeypatch.setattr(config, 'get_env', lambda x, y: '' if x == 'LEAPP_DEVEL_INITRAM_NETWORK' else y)
10981
with_mount_share = [MountEntry(name="nfs", mount="/mnt/data", tp='nfs',
11082
options="rw,nosuid,nodev,relatime,user_id=1000,group_id=1000")]
111-
with_systemdmount_entry = [SystemdMountEntry(node="nfs", path="n/a", model="n/a",
112-
wwn="n/a", fs_type='nfs', label="n/a",
113-
uuid="n/a")]
11483
with_fstab_entry = [FstabEntry(fs_spec="lithium:/mnt/data", fs_file="/mnt/data",
11584
fs_vfstype='nfs',
11685
fs_mntops="noauto,noatime,rsize=32768,wsize=32768",
11786
fs_freq="0", fs_passno="0")]
11887
current_actor_context.feed(StorageInfo(mount=with_mount_share,
119-
systemdmount=with_systemdmount_entry,
88+
systemdmount=[],
12089
fstab=with_fstab_entry))
12190
current_actor_context.run()
12291
report_fields = current_actor_context.consume(Report)[0].report

0 commit comments

Comments
 (0)