]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/pg_autoscaler: Reorderd if statement for the func: _maybe_adjust
authorKamoltat <ksirivad@redhat.com>
Wed, 1 Mar 2023 20:32:47 +0000 (20:32 +0000)
committerKamoltat <ksirivad@redhat.com>
Tue, 12 Sep 2023 17:31:15 +0000 (17:31 +0000)
Problem:

In the func `_maybe_adjust` we have this condition
where `if not p['would_adjust']: continue` which
would get triggered before `if p['pg_autoscale_mode'] == 'warn':`
if we don't have `pg_autoscale_mode` as `on`. This causes:
the autoscaler to not throw any warnings.

Solution:
Move `if p['pg_autoscale_mode'] == 'warn':` to be
higher than `if not p['would_adjust']: continue`.

Fixes: https://tracker.ceph.com/issues/58894
Signed-off-by: Kamoltat <ksirivad@redhat.com>
(cherry picked from commit c43fe7f07631bd0d795b711a100b9220b996ace0)

src/pybind/mgr/pg_autoscaler/module.py

index b7a95fc7b97b64e146ccdfcf8ac652a500ed5743..13e1cff9e8838655cf151df676847a2fc9153d1c 100644 (file)
@@ -719,8 +719,6 @@ class PgAutoscaler(MgrModule):
             if p['target_bytes'] > 0:
                 total_target_bytes[p['crush_root_id']] += p['target_bytes'] * p['raw_used_rate']
                 target_bytes_pools[p['crush_root_id']].append(p['pool_name'])
-            if not p['would_adjust']:
-                continue
             if p['pg_autoscale_mode'] == 'warn':
                 msg = 'Pool %s has %d placement groups, should have %d' % (
                     p['pool_name'],
@@ -730,7 +728,8 @@ class PgAutoscaler(MgrModule):
                     too_few.append(msg)
                 else:
                     too_many.append(msg)
-
+            if not p['would_adjust']:
+                continue
             if p['pg_autoscale_mode'] == 'on':
                 # Note that setting pg_num actually sets pg_num_target (see
                 # OSDMonitor.cc)