Skip to content

Commit 16bfec0

Browse files
committed
cleanup
Signed-off-by: Niclas Schad <niclas.schad@stackit.cloud>
1 parent 7f0c7bf commit 16bfec0

4 files changed

Lines changed: 4 additions & 68 deletions

File tree

pkg/csi/blockstorage/nodeserver.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,6 @@ func (ns *nodeServer) NodeGetInfo(ctx context.Context, _ *csi.NodeGetInfoRequest
302302
return nil, status.Errorf(codes.Internal, "[NodeGetInfo] unable to retrieve instance id of node %v", err)
303303
}
304304

305-
//flavor, err := ns.Metadata.GetFlavor(ctx)
306-
//if err != nil {
307-
// return nil, status.Errorf(codes.Internal, "[NodeGetInfo] unable to retrieve flavor of node %v", err)
308-
//}
309-
310-
// Subtract already mounted Volumes
311305
emptyPCIeRootPorts, err := mount.CountFreePCIeSlots()
312306
if err != nil {
313307
klog.Errorf("[NodeGetInfo] unable to retrieve PCIe root ports %v", err)
@@ -319,6 +313,7 @@ func (ns *nodeServer) NodeGetInfo(ctx context.Context, _ *csi.NodeGetInfoRequest
319313
klog.Errorf("[NodeGetInfo] unable to retrieve volume count %v", err)
320314
}
321315

316+
// maxVolumesPerNode is the result of all free/empty PCIClassBridgePCI ports plus all already mounted volumes.
322317
maxVolumesPerNode := emptyPCIeRootPorts + vols
323318

324319
nodeInfo := &csi.NodeGetInfoResponse{

pkg/csi/blockstorage/utils.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,6 @@ func ParseEndpoint(ep string) (proto, addr string, err error) {
8484
return "", "", fmt.Errorf("invalid endpoint: %v", ep)
8585
}
8686

87-
func DetermineMaxVolumesByFlavor(flavor string) int64 {
88-
flavorParts := strings.Split(flavor, ".")
89-
90-
// The following numbers were specified by the IaaS team. They are based on actual tests.
91-
switch {
92-
case strings.HasPrefix(flavor, "n"):
93-
// Flavors starting with 'n' are nvidia GPU flavors
94-
return 13
95-
case strings.HasSuffix(flavorParts[0], "2a"):
96-
// AMD 2nd Gen
97-
return 159
98-
default:
99-
// All other flavors can mount 28 volumes
100-
return 28
101-
}
102-
}
103-
10487
func logGRPC(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
10588
callID := serverGRPCEndpointCallCounter.Add(1)
10689

pkg/csi/blockstorage/utils_test.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

pkg/csi/util/mount/mount_linux.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var (
1919
)
2020

2121
const (
22-
RedhatVendor = "0x1af4"
23-
VirtioBlockDevice = "0x1042"
22+
// PCIClassBridgePCI Linux constant: https://github.com/torvalds/linux/blob/e43ffb69e0438cddd72aaa30898b4dc446f664f8/include/linux/pci_ids.h#L62
23+
PCIClassBridgePCI = "0x0604"
2424
)
2525

2626
func newDeviceStats(statfs *unix.Statfs_t) *DeviceStats {
@@ -63,7 +63,7 @@ func CountFreePCIeSlots() (int64, error) {
6363
class := strings.TrimSpace(string(classBuf))
6464

6565
// Class 0x060400 is a PCI-to-PCI bridge (standard for Root Ports)
66-
if strings.HasPrefix(class, "0x0604") {
66+
if strings.HasPrefix(class, PCIClassBridgePCI) {
6767
// 2. Check if the port has downstream devices
6868
// If the bridge has children, they appear as subdirectories
6969
// matching the PCI address format (e.g., 0000:01:00.0)
@@ -114,20 +114,3 @@ func CountLocalCSIVolumes(driverName string) (int64, error) {
114114

115115
return int64(volumeCount), nil
116116
}
117-
118-
func IsNonBlockDevice(devPath string, file os.DirEntry) bool {
119-
var isNonBlockDevice bool
120-
pciDevicePath := filepath.Join(devPath, file.Name())
121-
vendorBuf, err := os.ReadFile(filepath.Join(pciDevicePath, "vendor"))
122-
if err != nil {
123-
klog.Errorf("failed to read PCI device vendor %s : %v", pciDevicePath, err)
124-
}
125-
deviceBuf, err := os.ReadFile(filepath.Join(pciDevicePath, "device"))
126-
if err != nil {
127-
klog.Errorf("failed to read PCI device file %s : %v", pciDevicePath, err)
128-
}
129-
if strings.TrimSpace(string(vendorBuf)) == RedhatVendor && strings.TrimSpace(string(deviceBuf)) != VirtioBlockDevice {
130-
isNonBlockDevice = true
131-
}
132-
return isNonBlockDevice
133-
}

0 commit comments

Comments
 (0)