1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-10-31 18:30:33 +03:00
Files
mariadb-columnstore-engine/cmapi/cmapi_server/managers/upgrade/utils.py
mariadb-AlanMologorsky a76e153a1d feat(upgrade): MCOL-6028 upgrade MVP with repo-managed flow, prechecks, and other enhancements
Implements the initial upgrade capability across CMAPI and the CLI, including
repository setup, package operations, environment prechecks, and coordinated
cluster steps with progress reporting.

Details:
- CMAPI upgrade manager:
  - Add `cmapi/cmapi_server/managers/upgrade/` modules:
    - `repo.py`, `packages.py`, `preinstall.py`, `upgrade.py`, `utils.py` and `__init__.py`
  - Extend endpoints and routing to expose upgrade operations and status:
    - `cmapi_server/controllers/{endpoints.py, dispatcher.py, api_clients.py}`
    - `cmapi_server/managers/{application.py, process.py}`
    - Add improved constants and helpers for upgrade flow
- Backup/restore and safety:
  - Add `cmapi_server/managers/backup_restore.py`
  - Fix pre-upgrade backup regressions (due to `mcs_backup_manager.sh 3.17 changes`)
  - Improve cluster version validation; add `ignore_missmatch` override
- CLI enhancements:
  - Progress UI and richer feedback (`mcs_cluster_tool/tools_commands.py`, `README.md`, `mcs.1`)
  - Add steps to start MDB and start MCS during/after upgrade
  - Improved error surfacing for version validation
- Platform and packaging:
  - Ubuntu and Rocky Linux support
  - RHEL/DNF dry-run support
  - Distro detection and platform-dependent logic hardened
  - Logging improvements
- Updater service:
  - Add `cmapi/updater/cmapi_updater.service.template` and `cmapi_updater.sh` to make CMAPI update itself
- Docs:
  - Update mcs cli README and mcs.1 man file
  - Add `cmapi/updater/README.md`
2025-09-30 18:48:32 +04:00

45 lines
1.4 KiB
Python

import re
from dataclasses import dataclass
from functools import total_ordering
@total_ordering
@dataclass
class ComparableVersion:
version: str
def __post_init__(self):
self.version_nums = self._split_version(self.version)
def _split_version(self, version: str) -> list[int]:
# Drop epoch if present (debian style)
if ':' in version:
version = version.split(':', 1)[1]
# I'm not sure if ~ could be the first, but seems to be possible in some debians
# Trim at first suffix marker (+, ~) if any
for marker in ('+', '~'):
if marker in version:
version = version.split(marker, 1)[0]
break
# Remove leading .0s and split by . _ -
parts = re.split(r'[._-]', version)
return [int(p.lstrip('0') or '0') for p in parts]
def _normalized(self, other) -> tuple[list, list]:
"""Return two zero-padded version lists of equal length."""
v1 = self.version_nums.copy()
v2 = other.version_nums.copy()
max_len = max(len(v1), len(v2))
v1 += [0] * (max_len - len(v1))
v2 += [0] * (max_len - len(v2))
return v1, v2
def __eq__(self, other):
v1, v2 = self._normalized(other)
return v1 == v2
def __lt__(self, other):
v1, v2 = self._normalized(other)
return v1 < v2