Skip to content

Commit c922b11

Browse files
committed
fix logic
Signed-off-by: Niclas Schad <niclas.schad@stackit.cloud>
1 parent 98adde3 commit c922b11

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

pkg/csi/util/mount/mount.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func CountNonVirtioBlockDevices() (int64, error) {
162162
// 2. Check if the port has downstream devices
163163
// If the bridge has children, they appear as subdirectories
164164
// matching the PCI address format (e.g., 0000:01:00.0)
165-
isNonBLockDevice := false
165+
isNonBlockDevice := false
166166
files, err2 := os.ReadDir(devPath)
167167
if err2 != nil {
168168
klog.Errorf("failed to read dir %s : %v", devPath, err2)
@@ -171,12 +171,12 @@ func CountNonVirtioBlockDevices() (int64, error) {
171171
// Ignore PCI bus directories such as pci001 pci002 and pci010
172172
// Devices must follow <domain:bus:device.function> format
173173
if pciAddressRegex.MatchString(file.Name()) {
174-
isNonBLockDevice = probePCIeDevice(devPath, file, isNonBLockDevice)
174+
isNonBlockDevice = IsNonBlockDevice(devPath, file, isNonBlockDevice)
175175
break
176176
}
177177
}
178178

179-
if !isNonBLockDevice {
179+
if isNonBlockDevice {
180180
pcieSlotsOccupiedByNonBlockDevice++
181181
}
182182
} else {
@@ -187,7 +187,7 @@ func CountNonVirtioBlockDevices() (int64, error) {
187187
return int64(pcieSlotsOccupiedByNonBlockDevice), nil
188188
}
189189

190-
func probePCIeDevice(devPath string, file os.DirEntry, isNonBLockDevice bool) bool {
190+
func IsNonBlockDevice(devPath string, file os.DirEntry, isNonBLockDevice bool) bool {
191191
pciDevicePath := filepath.Join(devPath, file.Name())
192192
deviceBuf, err := os.ReadFile(filepath.Join(pciDevicePath, "device"))
193193
if err != nil {

0 commit comments

Comments
 (0)