- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6
Fix upstream mariadb upgrade #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -31,6 +31,7 @@ | |
| OLD_CLMYSQL_VERSIONS = ["5.0", "5.1"] | ||
| OLD_MYSQL_UPSTREAM_VERSIONS_CL7 = ["5.7", "5.6", "5.5"] | ||
| OLD_MYSQL_UPSTREAM_VERSIONS_CL8 = ["5.7", "5.6"] # adjust as needed for CL8 | ||
| OLD_MARIADB_UPSTREAM_VERSIONS_CL8 = ["10.3", "10.4"] # MariaDB versions to block for CL8 source | ||
|  | ||
|  | ||
| def build_install_list(prefix): | ||
|  | @@ -180,6 +181,33 @@ def clmysql_process(self, repofile_name, repofile_data): | |
| else: | ||
| api.current_logger().debug("No repos from CloudLinux repofile {} enabled, ignoring".format(repofile_name)) | ||
|  | ||
| def _make_upgrade_mariadb_url(self, mariadb_url, source_major, target_major): | ||
| """ | ||
| Maria URLs look like this: | ||
| baseurl = https://archive.mariadb.org/mariadb-10.3/yum/centos/7/x86_64 | ||
| baseurl = https://archive.mariadb.org/mariadb-10.7/yum/centos7-ppc64/ | ||
| baseurl = https://distrohub.kyiv.ua/mariadb/yum/11.8/rhel/$releasever/$basearch | ||
| baseurl = https://mariadb.gb.ssimn.org/yum/12.0/centos/$releasever/$basearch | ||
| baseurl = https://mariadb.gb.ssimn.org/yum/12.0/almalinux8-amd64/$releasever/$basearch | ||
| We want to replace the parts of the url to make them work with target os version. | ||
| """ | ||
|  | ||
| # Replace the first occurrence of source_major with target_major after 'yum' | ||
| url_parts = mariadb_url.split("yum", 1) | ||
| if len(url_parts) == 2: | ||
| # Replace major version in "/centos/7/" and /yum/12.0/almalinux9-amd64/, | ||
| # but do not replace it in /mariadb-10.7/yum/ | ||
| url_parts[1] = url_parts[1].replace("/{}/".format(source_major), "/{}/".format(target_major)) | ||
| url_parts[1] = url_parts[1].replace("{}-".format(source_major), "{}-".format(target_major)) | ||
| # Replace $releasever because upstream repos expect major version | ||
| # and cloudlinux provides major.minor as $releasever | ||
| url_parts[1] = url_parts[1].replace('$releasever', str(target_major)) | ||
| return "yum".join(url_parts) | ||
| else: | ||
| # TODO: fix in https://cloudlinux.atlassian.net/browse/CLOS-3490 | ||
|          | ||
| api.current_logger().warning("Unsupported repository URL={}, skipping".format(mariadb_url)) | ||
| return | ||
|  | ||
| def mariadb_process(self, repofile_name, repofile_data): | ||
| """ | ||
| Process upstream MariaDB options. | ||
|  | @@ -191,24 +219,36 @@ def mariadb_process(self, repofile_name, repofile_data): | |
| source_major = get_source_major_version() | ||
|  | ||
| for source_repo in repofile_data.data: | ||
| # Maria URLs look like this: | ||
| # baseurl = https://archive.mariadb.org/mariadb-10.3/yum/centos/7/x86_64 | ||
| # baseurl = https://archive.mariadb.org/mariadb-10.7/yum/centos7-ppc64/ | ||
| # We want to replace the source_major in OS name after /yum/ with target_major | ||
| target_repo = copy.deepcopy(source_repo) | ||
| target_repo.repoid = "{}-{}".format(target_repo.repoid, target_major) | ||
| # Replace the first occurrence of source_major with target_major after 'yum' | ||
| url_parts = target_repo.baseurl.split("yum", 1) | ||
| if len(url_parts) == 2: | ||
| # Replace only the first digit (source_major) after 'yum' | ||
| url_parts[1] = url_parts[1].replace(str(source_major), str(target_major), 1) | ||
| target_repo.baseurl = "yum".join(url_parts) | ||
| else: | ||
| # TODO: fix in https://cloudlinux.atlassian.net/browse/CLOS-3490 | ||
| api.current_logger().warning("Unsupported repository URL={}, skipping".format(target_repo.baseurl)) | ||
| return | ||
| target_repo.baseurl = self._make_upgrade_mariadb_url(source_repo.baseurl, source_major, target_major) | ||
|  | ||
| if target_repo.enabled: | ||
| # MariaDB 10.4 is not compatible with Leapp upgrade | ||
| if str(source_major) == "8" and any(ver in target_repo.baseurl for ver in OLD_MARIADB_UPSTREAM_VERSIONS_CL8): | ||
| reporting.create_report( | ||
| [ | ||
| reporting.Title("MariaDB version is not compatible with Leapp upgrade"), | ||
| reporting.Summary( | ||
| "MariaDB is installed on this system but is's version is not compatible with Leapp upgrade process. " | ||
| "The upgrade is blocked to prevent system instability. " | ||
| "This situation cannot be automatically resolved by Leapp. " | ||
| "Problematic repository: {0}".format(target_repo.repoid) | ||
| ), | ||
| reporting.Severity(reporting.Severity.MEDIUM), | ||
| reporting.Groups([reporting.Groups.REPOSITORY]), | ||
| reporting.Groups([reporting.Groups.INHIBITOR]), | ||
| reporting.Remediation( | ||
| hint=( | ||
| "Upgrade to a more recent MariaDB version, or " | ||
| "uninstall the MariaDB packages and disable the repository. " | ||
| "Note that you will also need to update any bindings (e.g., PHP or Python) " | ||
| "that are dependent on this MariaDB version." | ||
| ) | ||
| ), | ||
| ] | ||
| ) | ||
|  | ||
| api.current_logger().debug("Generating custom MariaDB repo: {}".format(target_repo.repoid)) | ||
| self.custom_repo_msgs.append( | ||
| CustomTargetRepository( | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import pytest | ||
|  | ||
| from leapp.libraries.actor import clmysqlrepositorysetup | ||
|  | ||
|  | ||
| @pytest.mark.parametrize( | ||
| "source_url,source_major,target_major,expected_url", | ||
| [ | ||
| # Test cases from docstring | ||
| ( | ||
| "https://archive.mariadb.org/mariadb-10.3/yum/centos/7/x86_64", | ||
| 7, 8, | ||
| "https://archive.mariadb.org/mariadb-10.3/yum/centos/8/x86_64", | ||
| ), | ||
| ( | ||
| "https://archive.mariadb.org/mariadb-10.7/yum/centos7-ppc64/", | ||
| 7, 8, | ||
| "https://archive.mariadb.org/mariadb-10.7/yum/centos8-ppc64/", | ||
| ), | ||
| ( | ||
| "https://distrohub.kyiv.ua/mariadb/yum/11.8/rhel/7/x86_64", | ||
| 7, 8, | ||
| "https://distrohub.kyiv.ua/mariadb/yum/11.8/rhel/8/x86_64", | ||
| ), | ||
| ( | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/centos/7/x86_64", | ||
| 7, 8, | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/centos/8/x86_64", | ||
| ), | ||
| ( | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/almalinux8-amd64/", | ||
| 8, 9, | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/almalinux9-amd64/", | ||
| ), | ||
|  | ||
| # Test with trailing slash | ||
| ( | ||
| "https://archive.mariadb.org/mariadb-10.3/yum/centos/7/x86_64/", | ||
| 7, 8, | ||
| "https://archive.mariadb.org/mariadb-10.3/yum/centos/8/x86_64/", | ||
| ), | ||
|  | ||
| # Test cases based on SSIMN.org mirror patterns | ||
| # RHEL patterns | ||
| ( | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/rhel8-amd64/", | ||
| 8, 9, | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/rhel9-amd64/", | ||
| ), | ||
|  | ||
| # Rocky Linux patterns | ||
| ( | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/rocky8-amd64/", | ||
| 8, 9, | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/rocky9-amd64/", | ||
| ), | ||
| ( | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/rockylinux8-amd64/", | ||
| 8, 9, | ||
| "https://mariadb.gb.ssimn.org/yum/12.0/rockylinux9-amd64/", | ||
| ), | ||
|  | ||
| # Test cases that should return None and log warning | ||
| ( | ||
| "https://example.com/mariadb/repo/centos/7/x86_64", | ||
| 7, 8, | ||
| None, | ||
| ), | ||
| ( | ||
| "https://example.com/mariadb/yum", | ||
| 7, 8, | ||
| None, | ||
| ), | ||
| ( | ||
| "", | ||
| 7, 8, | ||
| None, | ||
| ), | ||
| ( | ||
| None, | ||
| 7, 8, | ||
| None, | ||
| ), | ||
| ] | ||
| ) | ||
| def test_make_upgrade_mariadb_url(source_url, source_major, target_major, expected_url): | ||
| """Test URL transformation for various MariaDB repository URLs.""" | ||
| library = clmysqlrepositorysetup.MySqlRepositorySetupLibrary() | ||
| result = library._make_upgrade_mariadb_url(source_url, source_major, target_major) | ||
|  | ||
| assert result == expected_url | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
yumis a delimiter. It's not included.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it from the URL to avoid confusion.