From 15bd38eecee66670ad6eb41fac3099bfad69c196 Mon Sep 17 00:00:00 2001 From: Laura Flores Date: Thu, 18 Jan 2024 18:55:28 +0000 Subject: [PATCH] mgr: add CephReleases class to sustainably compare releases Changes how the upmap balancer compares min_mon_release to account for release names eventually wrapping around the alphabet. Signed-off-by: Laura Flores --- src/pybind/mgr/balancer/module.py | 18 ++++++++++++------ src/pybind/mgr/mgr_module.py | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 590f24653f0..2cbaf10c09f 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -374,13 +374,19 @@ class Module(MgrModule): """ Set balancer mode """ + min_compat_client = self.get_osdmap().dump().get('require_min_compat_client', '') if mode == Mode.upmap: - min_compat_client = self.get_osdmap().dump().get('require_min_compat_client', '') - if min_compat_client < 'luminous': # works well because version is alphabetized.. - warn = ('min_compat_client "%s" ' - '< "luminous", which is required for pg-upmap. ' - 'Try "ceph osd set-require-min-compat-client luminous" ' - 'before enabling this mode' % min_compat_client) + try: + release = CephReleases[min_compat_client] + if release.value < CephReleases.luminous.value: + warn = ('min_compat_client "%s" ' + '< "luminous", which is required for pg-upmap. ' + 'Try "ceph osd set-require-min-compat-client luminous" ' + 'before enabling this mode' % min_compat_client) + return (-errno.EPERM, '', warn) + except KeyError: + self.log.error('Unable to apply mode {} due to unknown min_compat_client {}'.format(mode, min_compat_client)) + warn = ('Unable to apply mode {} due to unknown min_compat_client {}.'.format(mode, min_compat_client)) return (-errno.EPERM, '', warn) elif mode == Mode.crush_compat: ms = MappingState(self.get_osdmap(), diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 6c83f277161..ef908bd81d3 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -83,6 +83,27 @@ PG_STATES = [ NFS_GANESHA_SUPPORTED_FSALS = ['CEPH', 'RGW'] NFS_POOL_NAME = '.nfs' +class CephReleases(IntEnum): + argonaut = 1 + bobtail = 2 + cuttlefish = 3 + dumpling = 4 + emperor = 5 + firefly = 6 + giant = 7 + hammer = 8 + infernalis = 9 + jewel = 10 + kraken = 11 + luminous = 12 + mimic = 13 + nautilus = 14 + octopus = 15 + pacific = 16 + quincy = 17 + reef = 18 + squid = 19 + maximum = 20 class NotifyType(str, Enum): mon_map = 'mon_map' -- 2.39.5