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.
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#
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: 779bb4- ceph-2: /var/lib/ juju/agents/ unit-ceph- osd-1/charm/ actions# pvs e3f2-4401- a2b8-c9c4f485d5 50 lvm2 a-- <10.00g 0
root@juju-
PV VG Fmt Attr PSize PFree
/dev/vdb ceph-5c48b342-
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 779bb4- ceph-2: /var/lib/ juju/agents/ unit-ceph- osd-1/charm#
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-
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 779bb4- ceph-2: /var/lib/ juju/agents/ unit-ceph- osd-1/charm/ actions# pvs e3f2-4401- a2b8-c9c4f485d5 50 lvm2 a-- <10.00g 0
Physical volume "/dev/vdc" successfully created.
root@juju-
PV VG Fmt Attr PSize PFree
/dev/vdb ceph-5c48b342-
/dev/vdc lvm2 --- 8.00g 8.00g
root@juju- 779bb4- ceph-2: /var/lib/ juju/agents/ unit-ceph- osd-1/charm# ./actions/zap-disk 779bb4- ceph-2: /var/lib/ juju/agents/ unit-ceph- osd-1/charm#
root@juju-
2021-08-13 11:42:23 INFO unit.ceph- osd/1.juju- log server.go:314 Cannot zap a device used by lvm