]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
purge_cluster: fix bug when building device list
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 16 May 2018 14:04:25 +0000 (16:04 +0200)
committerSébastien Han <seb@redhat.com>
Tue, 22 May 2018 14:43:48 +0000 (16:43 +0200)
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>
(cherry picked from commit 9cad113e2f22132d08208cd58462f11056c41305)

infrastructure-playbooks/purge-cluster.yml

index b8945f7b3a3b8f2f1529d6523fc3402c1c419b8e..9fe0ea4892d51c28735975acb6dc18df058ff403 100644 (file)
                                  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 }}"
   - 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 }}"