From 9f4033761329a0cd331b9c0b734ea411bc0b9e03 Mon Sep 17 00:00:00 2001 From: liuminjian <1441134290@qq.com> Date: Wed, 19 Jan 2022 19:49:41 +0800 Subject: [PATCH] fix(cleaner): fix disk partition cannot be released after creating lvm (#662) * fix the problem that the disk partition cannot be released after creating lvm Signed-off-by: liuminjian --- pkg/cleaner/jobcontroller.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/cleaner/jobcontroller.go b/pkg/cleaner/jobcontroller.go index be2df9797..c59049d19 100644 --- a/pkg/cleaner/jobcontroller.go +++ b/pkg/cleaner/jobcontroller.go @@ -104,7 +104,12 @@ func NewCleanupJob(bd *v1alpha1.BlockDevice, volMode VolumeMode, tolerations []v // wipefs erases the filesystem signature from the block // -a wipe all magic strings // -f force erasure - args := fmt.Sprintf("(fdisk -o Device -l %[1]s "+ + + args := fmt.Sprintf(""+ + "(pvs -o pv_name,vg_name|grep %[1]s|awk '{print $2}'"+ + "| xargs -I {} sh -c 'dmsetup info -c -o name --noheadings|grep ^{}- "+ + "| xargs -t -I {} dmsetup remove {} ') && "+ + "(fdisk -o Device -l %[1]s "+ "| grep \"^%[1]s\" "+ "| xargs -I '{}' wipefs -fa '{}') "+ "&& wipefs -fa %[1]s ",