Merge pull request #26022 from giuseppe/test-do-not-set-limits-on-dev-zero

test: use block devices for I/O limit tests
This commit is contained in:
openshift-merge-bot[bot]
2025-04-30 18:14:04 +00:00
committed by GitHub
11 changed files with 72 additions and 35 deletions

View File

@ -33,7 +33,8 @@ func GetContainerPidInformationDescriptors() ([]string, error) {
// [major:minor] is the device's major and minor numbers formatted as, for
// example, 2:0 and path is the path to the device node.
// Symlinks to nodes are ignored.
func FindDeviceNodes() (map[string]string, error) {
// If onlyBlockDevices is specified, character devices are ignored.
func FindDeviceNodes(onlyBlockDevices bool) (map[string]string, error) {
nodes := make(map[string]string)
err := filepath.WalkDir("/dev", func(path string, d fs.DirEntry, err error) error {
if err != nil {
@ -44,7 +45,13 @@ func FindDeviceNodes() (map[string]string, error) {
}
// If we aren't a device node, do nothing.
if d.Type()&(os.ModeDevice|os.ModeCharDevice) == 0 {
if d.Type()&os.ModeDevice == 0 {
return nil
}
// Ignore character devices, because it is not possible to set limits on them.
// os.ModeCharDevice is usable only when os.ModeDevice is set.
if onlyBlockDevices && d.Type()&os.ModeCharDevice != 0 {
return nil
}

View File

@ -5,6 +5,6 @@ package util
import "errors"
// FindDeviceNodes is not implemented anywhere except Linux.
func FindDeviceNodes() (map[string]string, error) {
func FindDeviceNodes(onlyBlockDevices bool) (map[string]string, error) {
return nil, errors.New("not supported on non-Linux OSes")
}