Skip to content

Commit

Permalink
Merge pull request #5955 from rvykydal/add-warning-for-ks-network-con…
Browse files Browse the repository at this point in the history
…fig-on-nfs

network: add warning for kickstart network configuration when running…
  • Loading branch information
rvykydal authored Nov 12, 2024
2 parents 03f5dfd + 1abacde commit a936d16
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
12 changes: 11 additions & 1 deletion pyanaconda/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.path import make_directories, open_with_perm, join_paths
from pyanaconda.core.constants import DRACUT_SHUTDOWN_EJECT, \
IPMI_ABORTED, PACKAGES_LIST_FILE
IPMI_ABORTED, PACKAGES_LIST_FILE, DRACUT_REPO_DIR
from pyanaconda.core.live_user import get_live_user
from pyanaconda.errors import RemovedModuleError

Expand Down Expand Up @@ -911,3 +911,13 @@ def get_image_packages_info(max_string_chars=0):
break
info_lines.append(' '.join(line.strip() for line in lines))
return info_lines


def is_stage2_on_nfs():
"""Is the installation running from image mounted via NFS?"""
for line in open("/proc/mounts").readlines():
values = line.split()
if len(values) > 2:
if values[1] == DRACUT_REPO_DIR and values[2] in ("nfs", "nfs4"):
return True
return False
6 changes: 6 additions & 0 deletions pyanaconda/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ def initialize_network():
log.debug("Devices found: %s",
[dev.device_name for dev in get_supported_devices()])

if util.is_stage2_on_nfs() and network_proxy.Kickstarted:
msg = "Using kickstart network configuration with installer image (stage2) provided " \
"via nfs server can freeze the installation."
log.warning(msg)
print("WARNING:", msg)

run_network_initialization_task(network_proxy.ApplyKickstartWithTask())
run_network_initialization_task(network_proxy.DumpMissingConfigFilesWithTask())

Expand Down
47 changes: 46 additions & 1 deletion tests/unit_tests/pyanaconda_tests/core/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
from threading import Lock
from unittest.mock import Mock, patch
from timer import timer
from io import StringIO
from textwrap import dedent

from pyanaconda.core.path import make_directories
from pyanaconda.errors import ExitError
from pyanaconda.core.process_watchers import WatchProcesses
from pyanaconda.core import util
from pyanaconda.core.util import synchronized, LazyObject
from pyanaconda.core.util import synchronized, LazyObject, is_stage2_on_nfs
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.live_user import User

Expand Down Expand Up @@ -815,6 +817,49 @@ def test_dracut_eject(self):
file_contents = "\n".join(f.readlines())
assert "eject " + devname in file_contents

@patch("pyanaconda.core.util.open")
def test_is_stage2_on_nfs(self, mock_open):
"""Test check for installation running on nfs."""
nfs_source_mounts = """
LiveOS_rootfs / overlay rw,seclabel,relatime,lowerdir=/run/rootfsbase,upperdir=/run/overlayfs,workdir=/run/ovlwork,uuid=on 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,size=401324k,nr_inodes=819200,mode=755,inode64 0 0
10.43.136.2:/mnt/data/trees/rawhide /run/install/repo nfs ro,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.43.136.2,mountvers=3,mountport=20
048,mountproto=udp,local_lock=all,addr=10.43.136.2 0 0
mqueue /dev/mqueue mqueue rw,seclabel,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/credentials/systemd-vconsole-setup.service tmpfs ro,seclabel,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap 0 0
10.43.136.2:/mnt/data/trees/rawhide /run/install/sources/mount-0000-nfs-device nfs rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.43.136.2
,mountvers=3,mountport=20048,mountproto=udp,local_lock=all,addr=10.43.136.2 0 0
"""
nfs_stage2_mounts = """
LiveOS_rootfs / overlay rw,seclabel,relatime,lowerdir=/run/rootfsbase,upperdir=/run/overlayfs,workdir=/run/ovlwork,uuid=on 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,size=401324k,nr_inodes=819200,mode=755,inode64 0 0
10.43.136.2:/mnt/data/users/rv/s2/rvm /run/install/repo nfs ro,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.43.136.2,mountvers=3,mountport=
mqueue /dev/mqueue mqueue rw,seclabel,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/credentials/systemd-vconsole-setup.service tmpfs ro,seclabel,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap 0 0
"""
no_nfs_mounts = """
LiveOS_rootfs / overlay rw,seclabel,relatime,lowerdir=/run/rootfsbase,upperdir=/run/overlayfs,workdir=/run/ovlwork,uuid=on 0 0
rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
mqueue /dev/mqueue mqueue rw,seclabel,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/credentials/systemd-vconsole-setup.service tmpfs ro,seclabel,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap 0 0
"""
nfs4_mounts = """
10.43.136.2:/mnt/data/users/rv/s2/rvm /run/install/repo nfs4 ro,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.43.136.2,mountvers=3,mountport=
"""
mock_open.return_value = StringIO(dedent(nfs_stage2_mounts))
assert is_stage2_on_nfs() is True

mock_open.return_value = StringIO(dedent(nfs_source_mounts))
assert is_stage2_on_nfs() is True

mock_open.return_value = StringIO(dedent(nfs4_mounts))
assert is_stage2_on_nfs() is True

mock_open.return_value = StringIO(dedent(no_nfs_mounts))
assert is_stage2_on_nfs() is False


class LazyObjectTestCase(unittest.TestCase):

Expand Down

0 comments on commit a936d16

Please sign in to comment.