From 99d9a45b6901d81e57b376d314d6bcd89768e1bc Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Wed, 23 Oct 2024 09:33:58 +0800 Subject: [PATCH] provisioner: ensure the device is ready before adding into volume group - The filesystem metadata would break the pvcreate Signed-off-by: Vicente Cheng (cherry picked from commit 02c0fb93b80fa5ba974e45da0e9beb04050d45d5) --- pkg/provisioner/lvm.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/provisioner/lvm.go b/pkg/provisioner/lvm.go index 387db25a..8f0672a8 100644 --- a/pkg/provisioner/lvm.go +++ b/pkg/provisioner/lvm.go @@ -40,8 +40,11 @@ func (l *LVMProvisioner) GetProvisionerName() string { return l.name } -func (l *LVMProvisioner) Format(string) (bool, bool, error) { - // LVM provisioner does not need format +// 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 _, err := utils.NewExecutor().Execute("wipefs", []string{"-a", devPath}); err != nil { + return false, false, err + } return true, false, nil }