Skip to content

Commit

Permalink
ceph-config: fix calculation of num_osds
Browse files Browse the repository at this point in the history
The number of OSDs defined by the `lvm_volumes` variable is added to
`num_osds` in task `Count number of osds for lvm scenario`. Therefore
theses devices must not be counted in task
`Set_fact num_osds (add existing osds)`.
There are currently three problems with the existing approach:
1. Bluestore DB and WAL devices are counted as OSDs
2. `lvm_volumes` supports a second notation to directly specify logical
   volumes instead of devices when the `data_vg` key exists.
   This scenario is not yet accounted for.
3. The `difference` filter used to remove devices from `lvm_volumes`
   returns a list of **unique** elements, thus not accounting for
   multiple OSDs on a single device

The first problem is solved by filtering the list of logical volumes for
devices used as `type` `block`.
For the second and third problem lists are created from `lvm_volumes`
containing either paths to devices or logical volumes devices.
For the second problem the output of `ceph-volume` is simply filtered
for `lv_path`s appearing in the list of logical volume devices described
above.
To solve the third problem the remaining OSDs in the output are
compiled into a list of their used devices, which is then filtered for
devices appearing in the list of devices from `lvm_volumes`.

Fixes: ceph#7435

Signed-off-by: Jan Horstmann <[email protected]>
  • Loading branch information
janhorstmann committed Mar 15, 2024
1 parent 49ec247 commit 3a33d3f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion roles/ceph-config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,21 @@
changed_when: false

- name: Set_fact num_osds (add existing osds)
vars:
lvm_volumes_devices: "{{ lvm_volumes | default([]) | rejectattr('data_vg', 'defined') | map(attribute='data') | list }}"
lvm_volumes_lv_paths: "{{
['/dev']
| product(
lvm_volumes | default([]) | selectattr('data_vg', 'defined') | map(attribute='data_vg')
| zip(
lvm_volumes | default([]) | selectattr('data_vg', 'defined') | map(attribute='data')
)
| map('join', '/')
)
| map('join', '/')
}}"
ansible.builtin.set_fact:
num_osds: "{{ num_osds | int + (lvm_list.stdout | default('{}') | from_json | dict2items | map(attribute='value') | flatten | map(attribute='devices') | sum(start=[]) | difference(lvm_volumes | default([]) | map(attribute='data')) | length | int) }}"
num_osds: "{{ num_osds | int + (lvm_list.stdout | default('{}') | from_json | dict2items | map(attribute='value') | flatten | selectattr('type', 'equalto', 'block') | rejectattr('lv_path', 'in', lvm_volumes_lv_paths) | map(attribute='devices') | flatten | reject('in', lvm_volumes_devices) | length | int) }}"

- name: Set osd related config facts
when: inventory_hostname in groups.get(osd_group_name, [])
Expand Down

0 comments on commit 3a33d3f

Please sign in to comment.