Comment 2 for bug 1858519

Revision history for this message
nikhil kshirsagar (nkshirsagar) wrote :

If the disk being zapped is used by lvm2 (i.e contains the lvm2 label and hasn't been pvremoved) it's safer to simply bail out than attempt teardown through forced pvremove,etc, because the disk being zapped might even be in use by an LV.

Submitted https://review.opendev.org/c/openstack/charm-ceph-osd/+/804520

Tested the patch:
root@juju-779bb4-ceph-2:/var/lib/juju/agents/unit-ceph-osd-1/charm/actions# pvs
  PV VG Fmt Attr PSize PFree
  /dev/vdb ceph-5c48b342-e3f2-4401-a2b8-c9c4f485d550 lvm2 a-- <10.00g 0

juju run-action --wait ceph-osd/1 zap-disk devices="/dev/vdc" i-really-mean-it=yes

root@juju-779bb4-ceph-2:/var/lib/juju/agents/unit-ceph-osd-1/charm# ./actions/zap-disk
  Failed to find physical volume "/dev/vdc".
  Failed to find physical volume "/dev/vdc".
Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Creating new GPT entries.
The operation has completed successfully.
1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0116351 s, 90.1 MB/s
100+0 records in
100+0 records out
51200 bytes (51 kB, 50 KiB) copied, 0.0165592 s, 3.1 MB/s
root@juju-779bb4-ceph-2:/var/lib/juju/agents/unit-ceph-osd-1/charm#

Now use vdc as a pv and check,

root@juju-779bb4-ceph-2:/var/lib/juju/agents/unit-ceph-osd-1/charm/actions# pvcreate /dev/vdc
  Physical volume "/dev/vdc" successfully created.
root@juju-779bb4-ceph-2:/var/lib/juju/agents/unit-ceph-osd-1/charm/actions# pvs
  PV VG Fmt Attr PSize PFree
  /dev/vdb ceph-5c48b342-e3f2-4401-a2b8-c9c4f485d550 lvm2 a-- <10.00g 0
  /dev/vdc lvm2 --- 8.00g 8.00g

root@juju-779bb4-ceph-2:/var/lib/juju/agents/unit-ceph-osd-1/charm# ./actions/zap-disk
root@juju-779bb4-ceph-2:/var/lib/juju/agents/unit-ceph-osd-1/charm#

2021-08-13 11:42:23 INFO unit.ceph-osd/1.juju-log server.go:314 Cannot zap a device used by lvm