osd: fix osd disk cleanup for mpath setups

ceph-volume raw list will return the main disk instead of the mpath
setup. `ceph-volume lvm zap` on the main disks fails. This PR uses
`lsblk /mnt/<diskreference> ` to fetch the actual mapath disk and use it
for cleaning

Signed-off-by: Santosh Pillai <sapillai@redhat.com>
(cherry picked from commit 1e9da0766e)
This commit is contained in:
Santosh Pillai authored and Mergify committed 2025-04-28 08:16:52 +00:00
1 parent b1729c5fe2
commit 859b886e12
1 file changed
+11 -8
+11 -8
View File
@@ -262,16 +262,19 @@ func DestroyOSD(context *clusterd.Context, clusterInfo *client.ClusterInfo, id i
}
logger.Infof("successfully destroyed osd.%d", osdInfo.ID)
if isPVC && osdInfo.Encrypted {
// remove the dm device
// in case of OSD on PVs, fetch the actual device name for the mounted /mnt/<pvc-name>
if isPVC {
pvcName := os.Getenv(oposd.PVCNameEnvVarName)
target := oposd.EncryptionDMName(pvcName, oposd.DmcryptBlockType)
err = removeEncryptedDevice(context, target)
if err != nil {
return nil, errors.Wrapf(err, "failed to remove dm device %q", target)
// remove the dm device
if osdInfo.Encrypted {
target := oposd.EncryptionDMName(pvcName, oposd.DmcryptBlockType)
err = removeEncryptedDevice(context, target)
if err != nil {
return nil, errors.Wrapf(err, "failed to remove dm device %q", target)
}
}
// ceph-volume uses `/dev/mapper/*` for encrypted disks. This is not a block device. So we need to fetch the corresponding
// block device for cleanup using `ceph-volume lvm zap`
// fetch the actual device for cleanup
blockPath := fmt.Sprintf("/mnt/%s", pvcName)
diskInfo, err := clusterd.PopulateDeviceInfo(blockPath, context.Executor)
if err != nil {