From 2e5194f5ab06b69a8a984563455b43346da38ade Mon Sep 17 00:00:00 2001 From: wangzhe Date: Tue, 20 Jun 2023 20:53:30 +0800 Subject: [PATCH] Add check items for ossfs. Signed-off-by: wangzhe --- .../el7toel8/actors/checkossfs/actor.py | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 repos/system_upgrade/el7toel8/actors/checkossfs/actor.py diff --git a/repos/system_upgrade/el7toel8/actors/checkossfs/actor.py b/repos/system_upgrade/el7toel8/actors/checkossfs/actor.py new file mode 100644 index 00000000..e96aa682 --- /dev/null +++ b/repos/system_upgrade/el7toel8/actors/checkossfs/actor.py @@ -0,0 +1,70 @@ +from leapp.actors import Actor +from leapp.models import StorageInfo +from leapp.reporting import Report, create_report +from leapp import reporting +from leapp.tags import ChecksPhaseTag, IPUWorkflowTag + + +class CheckOSSfs(Actor): + """ + Check if OSSFS filesystem is in use. If yes, inhibit the upgrade process. + + Actor looks for OSSFS in the following sources: /ets/fstab, mount and systemd-mount. + If there is OSSFS in any of the mentioned sources, actors inhibits the upgrade. + """ + name = "check_ossfs" + consumes = (StorageInfo,) + produces = (Report,) + tags = (ChecksPhaseTag, IPUWorkflowTag,) + + def process(self): + details = "OSSFS is currently not supported by the inplace upgrade.\n" \ + "We have found OSSFS usage at the following locations:\n" + + for storage in self.consume(StorageInfo): + # Check fstab + fstab_ossfs_mounts = [] + for fstab in storage.fstab: + if fstab.fs_spec.startswith('ossfs') and fstab.fs_vfstype == 'fuse' : + fstab_ossfs_mounts.append(" - {} {}\n".format(fstab.fs_spec, fstab.fs_file)) + + # Check mount + ossfs_mounts = [] + for mount in storage.mount: + if mount.tp.find('ossfs') != -1 : + ossfs_mounts.append(" - {} {}\n".format(mount.name, mount.mount)) + + # Check systemd-mount + systemd_ossfs_mounts = [] + for systemdmount in storage.systemdmount: + if systemdmount.fs_type.find('ossfs') != -1 : + # mountpoint is not available in the model + systemd_ossfs_mounts.append(" - {}\n".format(systemdmount.node)) + + if any((fstab_ossfs_mounts, ossfs_mounts, systemd_ossfs_mounts)): + if fstab_ossfs_mounts: + details += "- OSSFS shares found in /etc/fstab:\n" + details += ''.join(fstab_ossfs_mounts) + + if ossfs_mounts: + details += "- OSSFS shares currently mounted:\n" + details += ''.join(ossfs_mounts) + + if systemd_ossfs_mounts: + details += "- OSSFS mounts configured with systemd-mount:\n" + details += ''.join(systemd_ossfs_mounts) + + fstab_related_resource = [reporting.RelatedResource('file', '/etc/fstab')] if fstab_ossfs_mounts else [] + + create_report([ + reporting.Title("Use of OSSFS detected. Upgrade can't proceed"), + reporting.Summary(details), + reporting.Severity(reporting.Severity.HIGH), + reporting.Tags([ + reporting.Tags.FILESYSTEM, + reporting.Tags.NETWORK + ]), + reporting.Remediation(hint='Disable OSSFS temporarily for the upgrade if possible.'), + reporting.Flags([reporting.Flags.INHIBITOR]), + ] + fstab_related_resource + ) -- Gitee