From 740df379b73bf9b75f02f5435efc04906c8d05ed Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 30 Sep 2020 11:42:12 +0200 Subject: [PATCH] ceph_pool: improve pg_autoscaler support 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 --- library/ceph_pool.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/library/ceph_pool.py b/library/ceph_pool.py index 217316089..4104fdfda 100644 --- a/library/ceph_pool.py +++ b/library/ceph_pool.py @@ -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: