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

feat: filter child block devices also #254

Merged
merged 1 commit into from
Sep 29, 2022
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
3 changes: 3 additions & 0 deletions pkg/internal/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const (
// DeviceTypeROM is the device type for ROM devices in lsblk output
DeviceTypeROM = "rom"

// DeviceTypeLVM is the device type for lvm devices in lsblk output
DeviceTypeLVM = "lvm"

// mount string to find if a path is part of kubernetes
pluginString = "plugins/kubernetes.io"

Expand Down
2 changes: 2 additions & 0 deletions pkg/vgmanager/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ var FilterMap = map[string]func(internal.BlockDevice, internal.Executor) (bool,
return dev.IsUsableLoopDev(executor)
case internal.DeviceTypeROM:
return false, nil
case internal.DeviceTypeLVM:
return false, nil
default:
return true, nil
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/vgmanager/vgmanager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,16 @@ DeviceLoop:
// store device in deviceAgeMap
r.deviceAgeMap.storeDeviceAge(blockDevice.KName)

// check for partitions recursively
if blockDevice.HasChildren() {
childAvailableDevices, childDelayedDevices, err := r.filterAvailableDevices(blockDevice.Children)
if err != nil {
return []internal.BlockDevice{}, []internal.BlockDevice{}, err
}
availableDevices = append(availableDevices, childAvailableDevices...)
delayedDevices = append(delayedDevices, childDelayedDevices...)
}

devLogger := r.Log.WithValues("Device.Name", blockDevice.Name)
for name, filter := range FilterMap {
var valid bool
Expand Down