From 9cad113e2f22132d08208cd58462f11056c41305 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 16 May 2018 16:04:25 +0200 Subject: [PATCH] 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 --- infrastructure-playbooks/purge-cluster.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/infrastructure-playbooks/purge-cluster.yml b/infrastructure-playbooks/purge-cluster.yml index 8d1d9c9f0..71979471b 100644 --- a/infrastructure-playbooks/purge-cluster.yml +++ b/infrastructure-playbooks/purge-cluster.yml @@ -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 }}"