Skip to content

Commit b4a00cb

Browse files
committed
fix device on system not enable rdma_cm module
Signed-off-by: bingshen.wbs <[email protected]>
1 parent 5e0d8e0 commit b4a00cb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/deviceplugin/deviceplugin.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
const (
2929
dpSocketPath = "/var/lib/kubelet/device-plugins/%d-erdma.sock"
30+
rdmaCMDevice = "/dev/infiniband/rdma_cm"
3031
)
3132

3233
// ERDMADevicePlugin implements the Kubernetes device plugin API
@@ -55,6 +56,12 @@ func NewERDMADevicePlugin(devices []*types.ERdmaDeviceInfo, allocAllDevices, dev
5556
}
5657

5758
pluginEndpoint := fmt.Sprintf(dpSocketPath, time.Now().Unix())
59+
if allocRdmaCM {
60+
_, err := os.Stat(rdmaCMDevice)
61+
if err != nil {
62+
allocRdmaCM = false
63+
}
64+
}
5865
return &ERDMADevicePlugin{
5966
socket: pluginEndpoint,
6067
devices: devMap,
@@ -296,8 +303,8 @@ func (m *ERDMADevicePlugin) Allocate(ctx context.Context, r *pluginapi.AllocateR
296303
})
297304
if m.allocRdmaCM {
298305
devicePaths = append(devicePaths, &pluginapi.DeviceSpec{
299-
ContainerPath: "/dev/infiniband/rdma_cm",
300-
HostPath: "/dev/infiniband/rdma_cm",
306+
ContainerPath: rdmaCMDevice,
307+
HostPath: rdmaCMDevice,
301308
Permissions: "rw",
302309
})
303310
}

0 commit comments

Comments
 (0)