From b83aa873a66fd50ba8fd134a3478a53ccfffb51e Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Thu, 24 Oct 2024 09:32:31 +0800 Subject: [PATCH] provisioner/lvm: do not wipefs if the pv is already created - or the metadata would be broken Signed-off-by: Vicente Cheng --- pkg/provisioner/lvm.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/provisioner/lvm.go b/pkg/provisioner/lvm.go index 8f0672a8..92682791 100644 --- a/pkg/provisioner/lvm.go +++ b/pkg/provisioner/lvm.go @@ -42,8 +42,18 @@ func (l *LVMProvisioner) GetProvisionerName() string { // Format operation on the LVM use to ensure the device is clean and ready to be used by LVM. func (l *LVMProvisioner) Format(devPath string) (isFormatComplete, isRequeueNeeded bool, err error) { + // if the pv is created, skip wipefs. + // Because the device is already in use, wipefs will break the device. + pvResult, err := lvm.GetPVScanResult() + if err != nil { + return false, true, err + } + if _, found := pvResult[devPath]; found { + return true, false, nil + } + logrus.Infof("Wipe the device %s", devPath) if _, err := utils.NewExecutor().Execute("wipefs", []string{"-a", devPath}); err != nil { - return false, false, err + return false, true, err } return true, false, nil }