From 2cfaf1fc31c4c047cf4bc4fee8d71ad934f41d53 Mon Sep 17 00:00:00 2001 From: wangzhe Date: Mon, 12 Jun 2023 19:37:59 +0800 Subject: [PATCH] Fix bug caused by checknfs. The file system type may be "nfs3" or "nfs4". --- .../el7toel8/actors/checknfs/actor.py | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/repos/system_upgrade/el7toel8/actors/checknfs/actor.py b/repos/system_upgrade/el7toel8/actors/checknfs/actor.py index bd4c11c7..47626f74 100644 --- a/repos/system_upgrade/el7toel8/actors/checknfs/actor.py +++ b/repos/system_upgrade/el7toel8/actors/checknfs/actor.py @@ -20,31 +20,45 @@ class CheckNfs(Actor): def process(self): details = "NFS is currently not supported by the inplace upgrade.\n" \ "We have found NFS usage at the following locations:\n" - nfs_found = False + + def _is_nfs(a_type): + return a_type.startswith('nfs') and a_type != 'nfsd' for storage in self.consume(StorageInfo): # Check fstab + fstab_nfs_mounts = [] for fstab in storage.fstab: - if fstab.fs_vfstype == "nfs": - nfs_found = True - details += "- One or more NFS entries in /etc/fstab\n" - break + if _is_nfs(fstab.fs_vfstype): + fstab_nfs_mounts.append(" - {} {}\n".format(fstab.fs_spec, fstab.fs_file)) # Check mount + nfs_mounts = [] for mount in storage.mount: - if mount.tp == "nfs": - nfs_found = True - details += "- Currently mounted NFS shares\n" - break + 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 systemdmount.fs_type == "nfs": - nfs_found = True - details += "- One or more configured NFS mounts in systemd-mount\n" - break + 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 fstab_nfs_mounts: + details += "- NFS shares found in /etc/fstab:\n" + details += ''.join(fstab_nfs_mounts) + + if nfs_mounts: + 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 [] - if nfs_found: create_report([ reporting.Title("Use of NFS detected. Upgrade can't proceed"), reporting.Summary(details), @@ -55,5 +69,5 @@ class CheckNfs(Actor): ]), reporting.Remediation(hint='Disable NFS temporarily for the upgrade if possible.'), reporting.Flags([reporting.Flags.INHIBITOR]), - reporting.RelatedResource('file', '/etc/fstab') - ]) + ] + fstab_related_resource + ) -- Gitee