library: add missing `target_size_ratio` parameter support in ceph_pool module

When creating a new pool, target_size_ratio was ignored by ansible module ceph_pool.py.
target_size_ratio is now used when pg_autoscale_mode is on.
Tests added to library tests.
This adds too the use in the role ceph-rgw.

Signed-off-by: Fabien Brachere <fabien.brachere@celeste.fr>
(cherry picked from commit 4026ba9da1)
pull/6151/head
Fabien Brachere 2020-12-16 07:33:36 +01:00 committed by Dimitri Savineau
parent a2704581b1
commit ba3db6be9f
3 changed files with 11 additions and 2 deletions

View File

@ -452,6 +452,9 @@ def create_pool(cluster,
user_pool_config['pg_num']['value'],
'--pgp_num',
user_pool_config['pgp_num']['value']])
elif user_pool_config['target_size_ratio']['value']:
args.extend(['--target_size_ratio',
user_pool_config['target_size_ratio']['value']])
if user_pool_config['type']['value'] == 'replicated':
args.extend([user_pool_config['crush_rule']['value'],

View File

@ -35,6 +35,7 @@
pg_num: "{{ item.value.pg_num | default(omit) }}"
pgp_num: "{{ item.value.pgp_num | default(omit) }}"
size: "{{ item.value.size | default(omit) }}"
target_size_ratio: "{{ item.value.target_size_ratio | default(omit) }}"
pool_type: erasure
erasure_profile: "{{ item.value.ec_profile }}"
application: rgw
@ -56,6 +57,7 @@
pgp_num: "{{ item.value.pgp_num | default(omit) }}"
size: "{{ item.value.size | default(omit) }}"
min_size: "{{ item.value.min_size | default(omit) }}"
target_size_ratio: "{{ item.value.target_size_ratio | default(omit) }}"
pool_type: replicated
rule_name: "{{ item.value.rule_name | default(ceph_osd_pool_default_crush_rule_name) }}"
application: rgw

View File

@ -82,7 +82,7 @@ class TestCephPoolModule(object):
# 'target_size_ratio' is a key present in the dict above
# 'options': {}
# see comment in get_pool_details() for more details
'target_size_ratio': None,
'target_size_ratio': 0.3,
'application_metadata': {
'rbd': {}
},
@ -105,7 +105,7 @@ class TestCephPoolModule(object):
'cli_set_opt': 'pg_autoscale_mode'
},
'target_size_ratio': {
'value': None,
'value': '0.3',
'cli_set_opt': 'target_size_ratio'
},
'application': {
@ -430,6 +430,8 @@ class TestCephPoolModule(object):
'create',
self.fake_user_pool_config['pool_name']['value'],
self.fake_user_pool_config['type']['value'],
'--target_size_ratio',
self.fake_user_pool_config['target_size_ratio']['value'],
self.fake_user_pool_config['crush_rule']['value'],
'--expected_num_objects',
self.fake_user_pool_config['expected_num_objects']['value'],
@ -522,6 +524,8 @@ class TestCephPoolModule(object):
'create',
self.fake_user_pool_config['pool_name']['value'],
self.fake_user_pool_config['type']['value'],
'--target_size_ratio',
self.fake_user_pool_config['target_size_ratio']['value'],
self.fake_user_pool_config['erasure_profile']['value'],
self.fake_user_pool_config['crush_rule']['value'],
'--expected_num_objects',