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 two issues encountered when testing LHv2 provisioning #142

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions pkg/controller/blockdevice/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package blockdevice
import (
"fmt"
"reflect"
"strings"
"sync"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -242,6 +243,13 @@ func convertBlockDeviceListToMap(bdList *diskv1.BlockDeviceList) (map[string]*di
// returns true.
func (s *Scanner) ApplyExcludeFiltersForDisk(disk *block.Disk) bool {
for _, filter := range s.ExcludeFilters {
if strings.HasPrefix(disk.Name, "dm-") {
// None of the existing filters can handle this case, but
// we need to exclude /dev/dm-* devices because they appear
// when LHv2 volumes are attached to VMs.
logrus.Debugf("block device /dev/%s ignored because it's a dm device", disk.Name)
return true
}
if filter.ApplyDiskFilter(disk) {
logrus.Debugf("block device /dev/%s ignored by %s", disk.Name, filter.Name)
return true
Expand Down
14 changes: 12 additions & 2 deletions pkg/filter/vendor_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import (
const (
vendorFilterName = "vendor filter"
vendorFilterDefaultLonghorn = "longhorn"
// This is a hack to make sure we skip active longhorn v2 volumes,
// which appear as /dev/nvme* devices. They don't have a vendor,
// but do specify ID_MODEL=SPDK bdev Controller...
modelFilterDefaultSPDK = "SPDK bdev Controller"
)

var (
defaultExcludedVendors = []string{vendorFilterDefaultLonghorn}
defaultExcludedVendors = []string{vendorFilterDefaultLonghorn, modelFilterDefaultSPDK}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like to change the name of this variable?
Now, we mixed the vendor/module into this slice.

I do not have a strong opinion about changing the name. If you want to keep it, I am also okay with that.
Thanks!

Copy link
Contributor Author

@tserong tserong Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep it for now - I know it's a bit silly/incorrect, I just didn't rename it given that I want to rework all this filter stuff anyway separately for harvester/harvester#5059, and keeping the name avoids also tweaking the SetExcludeFilters() function in this commit.

)

type vendorFilter struct {
Expand All @@ -36,5 +40,11 @@ func (vf *vendorFilter) Match(blockDevice *block.Disk) bool {
if blockDevice.Vendor != "" && utils.MatchesIgnoredCase(vf.vendors, blockDevice.Vendor) {
return true
}
return blockDevice.BusPath != "" && utils.ContainsIgnoredCase(vf.vendors, blockDevice.BusPath)
if blockDevice.BusPath != "" && utils.ContainsIgnoredCase(vf.vendors, blockDevice.BusPath) {
return true
}
if blockDevice.Model != "" && utils.MatchesIgnoredCase(vf.vendors, blockDevice.Model) {
return true
}
return false
}
10 changes: 6 additions & 4 deletions pkg/provisioner/longhornv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ func (p *LonghornV2Provisioner) Update() (isRequeueNeeded bool, err error) {

// Sync disk driver
if targetDisk, found := p.nodeObj.Spec.Disks[p.device.Name]; found {
nodeCpy := p.nodeObj.DeepCopy()
nodeObjCpy := p.nodeObj.DeepCopy()
targetDisk.DiskDriver = p.device.Spec.Provisioner.Longhorn.DiskDriver
nodeCpy.Spec.Disks[p.device.Name] = targetDisk
if _, err = p.nodesClient.Update(nodeCpy); err != nil {
isRequeueNeeded = true
nodeObjCpy.Spec.Disks[p.device.Name] = targetDisk
if !reflect.DeepEqual(p.nodeObj, nodeObjCpy) {
if _, err = p.nodesClient.Update(nodeObjCpy); err != nil {
isRequeueNeeded = true
}
}
}
return
Expand Down
Loading