purge_cluster: fix bug when building device list

there is some leftover on devices when purging osds because of a invalid
device list construction.

typical error:
```
changed: [osd3] => (item=/dev/sda sda1) => {
    "changed": true,
    "cmd": "# if the disk passed is a raw device AND the boot system disk\n if parted -s \"/dev/sda sda1\" print | grep -sq boot; then\n echo \"Looks like /dev/sda sda1 has a boot partition,\"\n echo \"if you want to delete specific partitions point to the partition instead of the raw device\"\n echo \"Do not use your system disk!\"\n exit 1\n fi\n echo sgdisk -Z \"/dev/sda sda1\"\n echo dd if=/dev/zero of=\"/dev/sda sda1\" bs=1M count=200\n echo udevadm settle --timeout=600",
    "delta": "0:00:00.015188",
    "end": "2018-05-16 12:41:40.408597",
    "item": "/dev/sda sda1",
    "rc": 0,
    "start": "2018-05-16 12:41:40.393409"
}

STDOUT:

sgdisk -Z /dev/sda sda1
dd if=/dev/zero of=/dev/sda sda1 bs=1M count=200
udevadm settle --timeout=600

STDERR:

Error: Could not stat device /dev/sda sda1 - No such file or directory.
```

the devices list in the task `resolve parent device` isn't built
properly because the command used to resolve the parent device doesn't
return the expected output

eg:

```
changed: [osd3] => (item=/dev/sda1) => {
    "changed": true,
    "cmd": "echo /dev/$(lsblk -no pkname \"/dev/sda1\")",
    "delta": "0:00:00.013634",
    "end": "2018-05-16 12:41:09.068166",
    "item": "/dev/sda1",
    "rc": 0,
    "start": "2018-05-16 12:41:09.054532"
}

STDOUT:

/dev/sda sda1
```

For instance, it will result with a devices list like:
`['/dev/sda sda1', '/dev/sdb', '/dev/sdc sdc1']`
where we expect to have:
`['/dev/sda', '/dev/sdb', '/dev/sdc']`

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1492242

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/2609/head
Guillaume Abrioux 2018-05-16 16:04:25 +02:00 committed by Sébastien Han
parent d80a871a07
commit 9cad113e2f
1 changed files with 5 additions and 5 deletions

View File

@ -379,7 +379,7 @@
ceph_wal_partition_to_erase_path.stdout_lines }}"
- name: resolve parent device
shell: echo /dev/$(lsblk -no pkname "{{ item }}")
command: lsblk --nodeps -no pkname "{{ item }}"
register: tmp_resolved_parent_device
with_items:
- "{{ combined_devices_list }}"
@ -391,14 +391,14 @@
- name: zap ceph journal/block db/block wal partitions
shell: |
# if the disk passed is a raw device AND the boot system disk
if parted -s "{{ item }}" print | grep -sq boot; then
echo "Looks like {{ item }} has a boot partition,"
if parted -s "/dev/{{ item }}" print | grep -sq boot; then
echo "Looks like /dev/{{ item }} has a boot partition,"
echo "if you want to delete specific partitions point to the partition instead of the raw device"
echo "Do not use your system disk!"
exit 1
fi
sgdisk -Z "{{ item }}"
dd if=/dev/zero of="{{ item }}" bs=1M count=200
sgdisk -Z "/dev/{{ item }}"
dd if=/dev/zero of="/dev/{{ item }}" bs=1M count=200
udevadm settle --timeout=600
with_items:
- "{{ resolved_parent_device }}"