Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Call wipefs -a in LonghornV2Provisioner.Format() (backport #157) #158

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions pkg/provisioner/longhornv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
diskv1 "github.com/harvester/node-disk-manager/pkg/apis/harvesterhci.io/v1beta1"
"github.com/harvester/node-disk-manager/pkg/block"
ctllonghornv1 "github.com/harvester/node-disk-manager/pkg/generated/controllers/longhorn.io/v1beta2"
"github.com/harvester/node-disk-manager/pkg/utils"
)

type LonghornV2Provisioner struct {
Expand Down Expand Up @@ -55,11 +56,15 @@ func NewLHV2Provisioner(
}, nil
}

// Format is a no-op for V2 disks, but we still need to return
// isFormatComplete == true to indicate the disk is ready for use.
func (p *LonghornV2Provisioner) Format(string) (isFormatComplete, isRequeueNeeded bool, err error) {
isFormatComplete = true
return
// Format should really be a no-op for V2 disks given they just take the
// whole device, but for NVMe devices where Longhorn decides to use the
// nvme bdev driver, device activation will fail if there's an existing
// filesystem on the device, so we need to make sure to wipe before use.
func (p *LonghornV2Provisioner) 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
}

// UnFormat is a no-op for V2 disks
Expand Down
Loading