]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: add CephReleases class to sustainably compare releases
authorLaura Flores <lflores@ibm.com>
Thu, 18 Jan 2024 18:55:28 +0000 (18:55 +0000)
committerLaura Flores <lflores@ibm.com>
Fri, 26 Jan 2024 22:41:23 +0000 (22:41 +0000)
Changes how the upmap balancer compares min_mon_release
to account for release names eventually wrapping around the alphabet.

Signed-off-by: Laura Flores <lflores@ibm.com>
src/pybind/mgr/balancer/module.py
src/pybind/mgr/mgr_module.py

index 590f24653f0c40509b39296a054380da0d2904e7..2cbaf10c09fe3f96a8bd8495edab3ff296e35086 100644 (file)
@@ -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(),
index 6c83f2771619f0991c79286a2b3fab39be8a7861..ef908bd81d384ca293f15f4a2dd629cc455d928d 100644 (file)
@@ -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'