From: Laura Flores Date: Thu, 18 Jan 2024 18:55:28 +0000 (+0000) Subject: mgr: add CephReleases class to sustainably compare releases X-Git-Tag: v19.3.0~143^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=15bd38eecee66670ad6eb41fac3099bfad69c196;p=ceph.git 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 --- diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 590f24653f0c..2cbaf10c09fe 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 6c83f2771619..ef908bd81d38 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'