From 74bbd34e7c783ea9cb77744abc42cef7be75fb73 Mon Sep 17 00:00:00 2001 From: Mikhail Sandakov Date: Mon, 29 Jul 2024 14:14:09 +0300 Subject: [PATCH 1/2] Fix requirements for plesk version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eed20e8..8a5a146 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Do not use the script if any of the following is true: - **More than one kernel named interfaces (like ethX) are not supported**. Stability of such names are not guaranteed, so leapp prevent the conversion in such cases. ## Requirements -- Plesk version is more than five releases behind the latest version. +- Plesk version is not older than five releases back from the latest version - CloudLinux 7.9 or later. - grub2 is installed - At least 5 GB of free disk space. From 6b9ee738d81c976fb2578add59909b8198820ddf Mon Sep 17 00:00:00 2001 From: Mikhail Sandakov Date: Fri, 26 Jul 2024 10:01:02 +0300 Subject: [PATCH 2/2] Support cl-mariadb installed by guvernor --- cloudlinux7to8/actions/mariadb.py | 109 +++++++++++++++++++++++++++++- cloudlinux7to8/upgrader.py | 3 + dist-upgrader | 2 +- 3 files changed, 111 insertions(+), 3 deletions(-) diff --git a/cloudlinux7to8/actions/mariadb.py b/cloudlinux7to8/actions/mariadb.py index 76fedaf..7af7074 100644 --- a/cloudlinux7to8/actions/mariadb.py +++ b/cloudlinux7to8/actions/mariadb.py @@ -11,6 +11,7 @@ KNOWN_MARIADB_REPO_FILES = [ "mariadb.repo", "mariadb10.repo", + "cl-mysql.repo" ] MARIADB_PACKAGES = [ "MariaDB-client", @@ -27,6 +28,20 @@ def _find_mariadb_repo_files() -> typing.List[str]: return files.find_files_case_insensitive("/etc/yum.repos.d", KNOWN_MARIADB_REPO_FILES) +def _is_governor_mariadb_installed() -> bool: + if not mariadb.is_mariadb_installed() and not mariadb.is_mysql_installed(): + return False + + repofiles = _find_mariadb_repo_files() + for repofile in repofiles: + for repo in rpm.extract_repodata(repofile): + _, _, repo_baseurl, _, _, _ = repo + if repo_baseurl and "repo.cloudlinux.com" in repo_baseurl and ("cl-mariadb" in repo_baseurl or "cl-mysql" in repo_baseurl): + return True + + return False + + class AssertMariadbRepoAvailable(action.CheckAction): def __init__(self) -> None: self.name = "check mariadb repo available" @@ -70,7 +85,7 @@ def __init__(self) -> None: self.name = "update modern mariadb" def _is_required(self) -> bool: - return mariadb.is_mariadb_installed() and mariadb.get_installed_mariadb_version() > MARIADB_VERSION_ON_ALMA + return mariadb.is_mariadb_installed() and mariadb.get_installed_mariadb_version() > MARIADB_VERSION_ON_ALMA and not _is_governor_mariadb_installed() def _prepare_action(self) -> action.ActionResult: repofiles = _find_mariadb_repo_files() @@ -113,7 +128,7 @@ def __init__(self) -> None: self.name = "updating mariadb databases" def _is_required(self) -> bool: - return mariadb.is_mariadb_installed() and not mariadb.get_installed_mariadb_version() > MARIADB_VERSION_ON_ALMA + return mariadb.is_mariadb_installed() and not mariadb.get_installed_mariadb_version() > MARIADB_VERSION_ON_ALMA and not _is_governor_mariadb_installed() def _prepare_action(self) -> action.ActionResult: _remove_mariadb_packages() @@ -148,6 +163,96 @@ def estimate_post_time(self) -> int: return 2 * 60 +FIRST_SUPPORTED_GOVERNOR_MARIADB_VERSION = mariadb.MariaDBVersion("10.2.44") + + +class AssertMinGovernorMariadbVersion(action.CheckAction): + minimal_version: mariadb.MariaDBVersion + + def __init__(self, version: mariadb.MariaDBVersion) -> None: + self.name = "check minimum guvernor mariadb version" + self.minimal_version = version + self.description = f""" +The installed version of MariaDB is incompatible with the conversion process. To proceed, update MariaDB using Governor to version {str(self.minimal_version)!r} or later. +""" + + def _do_check(self) -> bool: + if not mariadb.is_mariadb_installed() or not _is_governor_mariadb_installed(): + return True + + return mariadb.get_installed_mariadb_version() >= self.minimal_version + + +class AssertGovernorMysqlNotInstalled(action.CheckAction): + minimal_version: mariadb.MariaDBVersion + + def __init__(self, version: mariadb.MariaDBVersion) -> None: + self.name = "check minimum governor mariadb version" + self.minimal_version = version + self.description = f""" +MySQL installed by Governor is not compatible with the conversion process. To continue, use Governor to update MariaDB to at least version {str(self.minimal_version)!r}. +""" + + def _do_check(self) -> bool: + return not mariadb.is_mysql_installed() or not _is_governor_mariadb_installed() + + +class UpdateGuvernorMariadb(action.ActiveAction): + def __init__(self) -> None: + self.name = "update modern mariadb installed from governor" + + def _is_required(self) -> bool: + if not mariadb.is_mariadb_installed() or not _is_governor_mariadb_installed(): + return False + # Actually the version should be checked by the AssertMinGovernorMariadbVersion pre-checker + # Therefore, if this execution occurs, we have likely forgotten to include the pre-checker in the process. + if mariadb.get_installed_mariadb_version() < FIRST_SUPPORTED_GOVERNOR_MARIADB_VERSION: + raise Exception(f"The installed version of MariaDB is not compatible with the conversion process. Please use Governor to update MariaDB to version {str(FIRST_SUPPORTED_GOVERNOR_MARIADB_VERSION)!r} or later.") + + return True + + def _prepare_action(self) -> action.ActionResult: + repofiles = _find_mariadb_repo_files() + if len(repofiles) == 0: + raise Exception("Mariadb installed from unknown repository. Please check the '{}' file is present".format("/etc/yum.repos.d/mariadb.repo")) + + log.debug("Add MariaDB repository files '{}' mapping".format(repofiles[0])) + leapp_configs.add_repositories_mapping(repofiles) + + # Unfortunately we can't rule source repositories for cl-MariaDB* packages at this point + # because they based on dnf modules, which will not be available in scope of leapp script. + # So we will have to reinstall packages after conversion process on CloudLinux 8 side. + return action.ActionResult() + + def _post_action(self) -> action.ActionResult: + repofiles = _find_mariadb_repo_files() + if len(repofiles) == 0: + return action.ActionResult() + + for repofile in repofiles: + leapp_configs.adopt_repositories(repofile) + + mariadb_packages = rpm.get_installed_packages_list("cl-MariaDB*") + mariadb_version = mariadb.get_installed_mariadb_version() + mariadb_module = f"mariadb:cl-MariaDB{mariadb_version.major}{mariadb_version.minor}" + log.debug(f"Going to reinstall following packages with enabled dnf module {mariadb_module!r}: {mariadb_packages}") + + rpm.remove_packages(rpm.filter_installed_packages(mariadb_packages)) + util.logged_check_call(["dnf", "module", "enable", mariadb_module]) + rpm.install_packages(mariadb_packages) + + return action.ActionResult() + + def _revert_action(self) -> action.ActionResult: + return action.ActionResult() + + def estimate_prepare_time(self) -> int: + return 30 + + def estimate_post_time(self) -> int: + return 60 + + class AddMysqlConnector(action.ActiveAction): def __init__(self) -> None: self.name = "install mysql connector" diff --git a/cloudlinux7to8/upgrader.py b/cloudlinux7to8/upgrader.py index 2f8e666..cef70a1 100644 --- a/cloudlinux7to8/upgrader.py +++ b/cloudlinux7to8/upgrader.py @@ -157,6 +157,7 @@ def construct_actions( "Update databases": [ custom_actions.UpdateMariadbDatabase(), custom_actions.UpdateModernMariadb(), + custom_actions.UpdateGuvernorMariadb(), custom_actions.AddMysqlConnector(), ], "Repositories handling": [ @@ -224,6 +225,8 @@ def get_check_actions( custom_actions.AssertPackagesUpToDate(), custom_actions.AssertNoOutdatedLetsEncryptExtRepository(), custom_actions.AssertPleskRepositoriesNotNoneLink(), + custom_actions.AssertMinGovernorMariadbVersion(custom_actions.FIRST_SUPPORTED_GOVERNOR_MARIADB_VERSION), + custom_actions.AssertGovernorMysqlNotInstalled(custom_actions.FIRST_SUPPORTED_GOVERNOR_MARIADB_VERSION), ] if not self.upgrade_postgres_allowed: diff --git a/dist-upgrader b/dist-upgrader index 66c0619..e59c050 160000 --- a/dist-upgrader +++ b/dist-upgrader @@ -1 +1 @@ -Subproject commit 66c06196b237d980d0d944b7ef8c0850cf4169c9 +Subproject commit e59c05070657369af7719b82d0104c14b8e15365