]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
osd: refact osd pool creation
authorGuillaume Abrioux <gabrioux@redhat.com>
Fri, 28 Feb 2020 10:41:00 +0000 (11:41 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 6 Mar 2020 15:10:03 +0000 (16:10 +0100)
Currently, the command executed is wrong, eg:

```
  cmd:
  - podman
  - exec
  - ceph-mon-controller-0
  - ceph
  - --cluster
  - ceph
  - osd
  - pool
  - create
  - volumes
  - '32'
  - '32'
  - replicated_rule
  - '1'
  delta: '0:00:01.625525'
  end: '2020-02-27 16:41:05.232705'
  item:
```

From documentation, the osd pool creation command is :

```
ceph osd pool create {pool-name} {pg-num} [{pgp-num}] [replicated] \
     [crush-rule-name] [expected-num-objects]
ceph osd pool create {pool-name} {pg-num}  {pgp-num}   erasure \
     [erasure-code-profile] [crush-rule-name] [expected_num_objects]
```

it means we pass '1' (from item.type) as value for
`expected_num_objects` by default which is very likely not what we want.

Also, this commit modifies the default value when no `rule_name` is set
to use the existing variable `osd_pool_default_crush_rule`

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1808495
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit bf1f125d718c386264f19ce82cae5060ac166ce6)

roles/ceph-client/tasks/create_users_keys.yml
roles/ceph-mds/tasks/create_mds_filesystems.yml
roles/ceph-osd/tasks/openstack_config.yml

index 8f6543ad9568a5f7faf94f9e7b8179afb7be66e4..df44b505cf9a0f59b3f3d73435bdf82553766979 100644 (file)
         osd pool create {{ item.0.name }}
         {{ item.0.pg_num | default(osd_pool_default_pg_num) }}
         {{ item.0.pgp_num | default(item.0.pg_num) | default(osd_pool_default_pg_num) }}
-        {{ 'replicated_rule' if not item.0.rule_name | default('replicated_rule') else item.0.rule_name | default('replicated_rule') }}
-        {{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }}
-        {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile %}
+        {%- if item.0.type | default(1) | int == 1 or item.0.type | default('replicated') == 'replicated' %}
+        replicated
+        {{ item.0.rule_name | default(osd_pool_default_crush_rule) }}
+        {%- else %}
+        erasure
         {{ item.0.erasure_profile }}
+        {{ item.0.rule_name | default('erasure-code') }}
         {%- endif %}
-        {{ item.0.expected_num_objects | default('') }}
+        {{ item.0.expected_num_objects | default(0) }}
       with_together:
         - "{{ pools }}"
         - "{{ created_pools.results }}"
index 3e22a047e82f6a232e704ec79c82ef0d0afc4055..60aad2f5575c103a7670e4e51174059a6387f119 100644 (file)
             osd pool create {{ item.name }}
             {{ item.pg_num | default(osd_pool_default_pg_num) }}
             {{ item.pgp_num | default(item.pg_num) | default(osd_pool_default_pg_num) }}
-            {{ 'replicated_rule' if not item.rule_name | default('replicated_rule') else item.rule_name | default('replicated_rule') }}
-            {{ 1 if item.type|default(1) == 'replicated' else 3 if item.type|default(1) == 'erasure' else item.type|default(1) }}
-            {%- if (item.type | default("1") == '3' or item.type | default("1") == 'erasure') and item.erasure_profile | length > 0 %}
+            {%- if item.type | default(1) | int == 1 or item.type | default('replicated') == 'replicated' %}
+            replicated
+            {{ item.rule_name | default(osd_pool_default_crush_rule) }}
+            {%- else %}
+            erasure
             {{ item.erasure_profile }}
+            {{ item.rule_name | default('erasure-code') }}
             {%- endif %}
-            {{ item.expected_num_objects | default('') }}
+            {{ item.expected_num_objects | default(0) }}
           changed_when: false
           with_items:
             - "{{ cephfs_pools }}"
index f551d628651a89dceb155d8dac2741f077176b81..9f351a574c7945f92b0ed3fad6e77eb62f2b79b3 100644 (file)
         osd pool create {{ item.0.name }}
         {{ item.0.pg_num | default(osd_pool_default_pg_num) }}
         {{ item.0.pgp_num | default(item.0.pg_num) | default(osd_pool_default_pg_num) }}
-        {{ 'replicated_rule' if not item.0.rule_name | default('replicated_rule') else item.0.rule_name | default('replicated_rule') }}
-        {{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }}
-        {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile %}
+        {%- if item.0.type | default(1) | int == 1 or item.0.type | default('replicated') == 'replicated' %}
+        replicated
+        {{ item.0.rule_name | default(osd_pool_default_crush_rule) }}
+        {%- else %}
+        erasure
         {{ item.0.erasure_profile }}
+        {{ item.0.rule_name | default('erasure-code') }}
         {%- endif %}
-        {{ item.0.expected_num_objects | default('') }}
+        {{ item.0.expected_num_objects | default(0) }}
       with_together:
         - "{{ openstack_pools | unique }}"
         - "{{ created_pools.results }}"