From: Sage Weil Date: Mon, 25 Jan 2021 22:47:16 +0000 (-0600) Subject: mgr/cephadm: verify container image version after we pull it X-Git-Tag: v16.2.0~207^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6dfe5e43135e08cec60e71590cf0bcd1cbbb280;p=ceph.git mgr/cephadm: verify container image version after we pull it Apply the version checks to make sure this upgrade/downgrade is possible. Signed-off-by: Sage Weil (cherry picked from commit 5147d0f9305d97bf251671da80200f92536d4862) --- diff --git a/src/pybind/mgr/cephadm/upgrade.py b/src/pybind/mgr/cephadm/upgrade.py index 181b0ff23e7..ff26aeb969a 100644 --- a/src/pybind/mgr/cephadm/upgrade.py +++ b/src/pybind/mgr/cephadm/upgrade.py @@ -58,6 +58,7 @@ class CephadmUpgrade: 'UPGRADE_NO_STANDBY_MGR', 'UPGRADE_FAILED_PULL', 'UPGRADE_REDEPLOY_DAEMON', + 'UPGRADE_BAD_TARGET_VERSION', ] def __init__(self, mgr: "CephadmOrchestrator"): @@ -94,7 +95,7 @@ class CephadmUpgrade: try: (major, minor, patch) = version.split('.') assert int(minor) >= 0 - assert int(patch) >= 0 + # patch might be a number or {number}-g{sha1} except: return 'version must be in the form X.Y.Z (e.g., 15.2.3)' if int(major) < 15 or (int(major) == 15 and int(minor) < 2): @@ -305,6 +306,16 @@ class CephadmUpgrade: logger.info('Upgrade: Target is version %s, container %s with id %s' % ( target_version, target_image, target_id)) + version_error = self._check_target_version(target_version) + if version_error: + self._fail_upgrade('UPGRADE_BAD_TARGET_VERSION', { + 'severity': 'error', + 'summary': f'Upgrade: cannot upgrade/downgrade to {target_version}', + 'count': 1, + 'detail': [version_error], + }) + return + image_settings = self.get_distinct_container_image_settings() daemons = self.mgr.cache.get_daemons()