Skip to content

Commit

Permalink
provisioner/lvm: do not wipefs if the pv is already created
Browse files Browse the repository at this point in the history
    - or the metadata would be broken

Signed-off-by: Vicente Cheng <[email protected]>
  • Loading branch information
Vicente-Cheng committed Oct 28, 2024
1 parent 02c0fb9 commit b83aa87
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/provisioner/lvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b83aa87

Please sign in to comment.