]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph_pool: improve pg_autoscaler support
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 30 Sep 2020 09:42:12 +0000 (11:42 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 2 Oct 2020 05:42:40 +0000 (07:42 +0200)
This commit modifies how the `pg_autoscaler` feature is handled by the
ceph_pool module.

1/ If a pool has the pg_autoscaler feature enabled, we shouldn't try to
update pg/pgp.
2/ Make it more readable

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
library/ceph_pool.py

index 217316089ad0cf15d4b59eeea4fe93bc8a7ba068..4104fdfda2f6a837a5cfe7baadcc9a7a00c3b4ab 100644 (file)
@@ -674,18 +674,27 @@ def run_module():
             user_pool_config['pg_placement_num'] = {'value': str(running_pool_details[2]['pg_placement_num']), 'cli_set_opt': 'pgp_num'}  # noqa: E501
             delta = compare_pool_config(user_pool_config,
                                         running_pool_details[2])
-            if (len(delta) > 0 and
-                    running_pool_details[2]['erasure_code_profile'] == "" and
-                    'size' not in delta.keys()):
-                rc, cmd, out, err = update_pool(module,
-                                                cluster,
-                                                name,
-                                                user,
-                                                user_key,
-                                                delta,
-                                                container_image=container_image)  # noqa: E501
-                if rc == 0:
-                    changed = True
+            if len(delta) > 0:
+                keys = list(delta.keys())
+                details = running_pool_details[2]
+                if details['erasure_code_profile'] and 'size' in keys:
+                    del delta['size']
+                if details['pg_autoscale_mode'] == 'on':
+                    delta.pop('pg_num', None)
+                    delta.pop('pgp_num', None)
+
+                if len(delta) == 0:
+                    out = "Skipping pool {}.\nUpdating either 'size' on an erasure-coded pool or 'pg_num'/'pgp_num' on a pg autoscaled pool is incompatible".format(name)  # noqa: E501
+                else:
+                    rc, cmd, out, err = update_pool(module,
+                                                    cluster,
+                                                    name,
+                                                    user,
+                                                    user_key,
+                                                    delta,
+                                                    container_image=container_image)  # noqa: E501
+                    if rc == 0:
+                        changed = True
             else:
                 out = "Pool {} already exists and there is nothing to update.".format(name)  # noqa: E501
         else: